import{S as os,i as rs,s as is,e as i,k as y,w as T,t as n,M as cs,c,d as a,m as g,a as p,x as U,h as o,b as v,G as t,g as m,y as J,q as k,o as C,B as q,v as ps,L as ns}from"../../chunks/vendor-hf-doc-builder.js";import{T as xt}from"../../chunks/Tip-hf-doc-builder.js";import{Y as ms}from"../../chunks/Youtube-hf-doc-builder.js";import{I as Bt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as se}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as ls,M as Xt}from"../../chunks/Markdown-hf-doc-builder.js";import"../../chunks/IconTensorflow-hf-doc-builder.js";function fs(S){let s,u,l,h,M;return{c(){s=i("p"),u=n("Consulta la "),l=i("a"),h=n("p\xE1gina de la tarea"),M=n(" de generaci\xF3n de res\xFAmenes para obtener m\xE1s informaci\xF3n sobre sus modelos, datasets y m\xE9tricas asociadas."),this.h()},l(b){s=c(b,"P",{});var j=p(s);u=o(j,"Consulta la "),l=c(j,"A",{href:!0,rel:!0});var Z=p(l);h=o(Z,"p\xE1gina de la tarea"),Z.forEach(a),M=o(j," de generaci\xF3n de res\xFAmenes para obtener m\xE1s informaci\xF3n sobre sus modelos, datasets y m\xE9tricas asociadas."),j.forEach(a),this.h()},h(){v(l,"href","https://huggingface.co/tasks/summarization"),v(l,"rel","nofollow")},m(b,j){m(b,s,j),t(s,u),t(s,l),t(l,h),t(s,M)},d(b){b&&a(s)}}}function us(S){let s,u;return s=new se({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRG1vZGVsKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=model)`}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p:ns,i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function ds(S){let s,u;return s=new Xt({props:{$$slots:{default:[us]},$$scope:{ctx:S}}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p(l,h){const M={};h&2&&(M.$$scope={dirty:h,ctx:l}),s.$set(M)},i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function hs(S){let s,u;return s=new se({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRG1vZGVsJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForSeq2Seq

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=model, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p:ns,i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function ys(S){let s,u;return s=new Xt({props:{$$slots:{default:[hs]},$$scope:{ctx:S}}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p(l,h){const M={};h&2&&(M.$$scope={dirty:h,ctx:l}),s.$set(M)},i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function gs(S){let s,u,l,h,M,b,j,Z;return{c(){s=i("p"),u=n("Para familiarizarte con el proceso para realizar fine-tuning sobre un modelo con "),l=i("code"),h=n("Trainer"),M=n(", \xA1mira el tutorial b\xE1sico "),b=i("a"),j=n("aqu\xED"),Z=n("!"),this.h()},l(_){s=c(_,"P",{});var w=p(s);u=o(w,"Para familiarizarte con el proceso para realizar fine-tuning sobre un modelo con "),l=c(w,"CODE",{});var G=p(l);h=o(G,"Trainer"),G.forEach(a),M=o(w,", \xA1mira el tutorial b\xE1sico "),b=c(w,"A",{href:!0});var B=p(b);j=o(B,"aqu\xED"),B.forEach(a),Z=o(w,"!"),w.forEach(a),this.h()},h(){v(b,"href","../training#finetune-with-trainer")},m(_,w){m(_,s,w),t(s,u),t(s,l),t(l,h),t(s,M),t(s,b),t(b,j),t(s,Z)},d(_){_&&a(s)}}}function bs(S){let s,u,l,h,M,b,j,Z,_,w,G,B,x,X,z,D,N,he,pe,H,L,Q,F,oe,ee,ye,O,W,le,K,me,R,V,Y;return j=new se({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnQ1LXNtYWxsJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, Seq2SeqTrainingArguments, Seq2SeqTrainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-small&quot;</span>)`}}),_=new xt({props:{$$slots:{default:[gs]},$$scope:{ctx:S}}}),V=new se({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIyLiUyRnJlc3VsdHMlMjIlMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBsZWFybmluZ19yYXRlJTNEMmUtNSUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfdHJhaW5fYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBzYXZlX3RvdGFsX2xpbWl0JTNEMyUyQyUwQSUyMCUyMCUyMCUyMG51bV90cmFpbl9lcG9jaHMlM0QxJTJDJTBBJTIwJTIwJTIwJTIwZnAxNiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfYmlsbHN1bSU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX2JpbGxzdW0lNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = Seq2SeqTrainingArguments(
<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>    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>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>    save_total_limit=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    fp16=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Seq2SeqTrainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_billsum[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_billsum[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<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(){s=i("p"),u=n("Carga T5 con "),l=i("code"),h=n("AutoModelForSeq2SeqLM"),M=n(":"),b=y(),T(j.$$.fragment),Z=y(),T(_.$$.fragment),w=y(),G=i("p"),B=n("En este punto, solo faltan tres pasos:"),x=y(),X=i("ol"),z=i("li"),D=n("Definir tus hiperpar\xE1metros de entrenamiento en "),N=i("code"),he=n("Seq2SeqTrainingArguments"),pe=n("."),H=y(),L=i("li"),Q=n("Pasarle los argumentos de entrenamiento a "),F=i("code"),oe=n("Seq2SeqTrainer"),ee=n(" junto con el modelo, dataset y data collator."),ye=y(),O=i("li"),W=n("Llamar "),le=i("code"),K=n("train()"),me=n(" para realizar el fine-tuning sobre tu modelo."),R=y(),T(V.$$.fragment)},l(d){s=c(d,"P",{});var E=p(s);u=o(E,"Carga T5 con "),l=c(E,"CODE",{});var A=p(l);h=o(A,"AutoModelForSeq2SeqLM"),A.forEach(a),M=o(E,":"),E.forEach(a),b=g(d),U(j.$$.fragment,d),Z=g(d),U(_.$$.fragment,d),w=g(d),G=c(d,"P",{});var ge=p(G);B=o(ge,"En este punto, solo faltan tres pasos:"),ge.forEach(a),x=g(d),X=c(d,"OL",{});var I=p(X);z=c(I,"LI",{});var fe=p(z);D=o(fe,"Definir tus hiperpar\xE1metros de entrenamiento en "),N=c(fe,"CODE",{});var te=p(N);he=o(te,"Seq2SeqTrainingArguments"),te.forEach(a),pe=o(fe,"."),fe.forEach(a),H=g(I),L=c(I,"LI",{});var P=p(L);Q=o(P,"Pasarle los argumentos de entrenamiento a "),F=c(P,"CODE",{});var Me=p(F);oe=o(Me,"Seq2SeqTrainer"),Me.forEach(a),ee=o(P," junto con el modelo, dataset y data collator."),P.forEach(a),ye=g(I),O=c(I,"LI",{});var re=p(O);W=o(re,"Llamar "),le=c(re,"CODE",{});var ae=p(le);K=o(ae,"train()"),ae.forEach(a),me=o(re," para realizar el fine-tuning sobre tu modelo."),re.forEach(a),I.forEach(a),R=g(d),U(V.$$.fragment,d)},m(d,E){m(d,s,E),t(s,u),t(s,l),t(l,h),t(s,M),m(d,b,E),J(j,d,E),m(d,Z,E),J(_,d,E),m(d,w,E),m(d,G,E),t(G,B),m(d,x,E),m(d,X,E),t(X,z),t(z,D),t(z,N),t(N,he),t(z,pe),t(X,H),t(X,L),t(L,Q),t(L,F),t(F,oe),t(L,ee),t(X,ye),t(X,O),t(O,W),t(O,le),t(le,K),t(O,me),m(d,R,E),J(V,d,E),Y=!0},p(d,E){const A={};E&2&&(A.$$scope={dirty:E,ctx:d}),_.$set(A)},i(d){Y||(k(j.$$.fragment,d),k(_.$$.fragment,d),k(V.$$.fragment,d),Y=!0)},o(d){C(j.$$.fragment,d),C(_.$$.fragment,d),C(V.$$.fragment,d),Y=!1},d(d){d&&a(s),d&&a(b),q(j,d),d&&a(Z),q(_,d),d&&a(w),d&&a(G),d&&a(x),d&&a(X),d&&a(R),q(V,d)}}}function Ms(S){let s,u;return s=new Xt({props:{$$slots:{default:[bs]},$$scope:{ctx:S}}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p(l,h){const M={};h&2&&(M.$$scope={dirty:h,ctx:l}),s.$set(M)},i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function $s(S){let s,u,l,h,M;return{c(){s=i("p"),u=n("Para familiarizarte con el fine-tuning con Keras, \xA1mira el tutorial b\xE1sico "),l=i("a"),h=n("aqu\xED"),M=n("!"),this.h()},l(b){s=c(b,"P",{});var j=p(s);u=o(j,"Para familiarizarte con el fine-tuning con Keras, \xA1mira el tutorial b\xE1sico "),l=c(j,"A",{href:!0});var Z=p(l);h=o(Z,"aqu\xED"),Z.forEach(a),M=o(j,"!"),j.forEach(a),this.h()},h(){v(l,"href","training#finetune-with-keras")},m(b,j){m(b,s,j),t(s,u),t(s,l),t(l,h),t(s,M)},d(b){b&&a(s)}}}function js(S){let s,u,l,h,M,b,j,Z,_,w,G,B,x,X,z,D,N,he,pe,H,L,Q,F,oe,ee,ye,O,W,le,K,me,R,V,Y,d,E,A,ge,I,fe,te,P,Me,re,ae,ue,be;return x=new se({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwdG9rZW5pemVkX2JpbGxzdW0lNUIlMjJ0cmFpbiUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCUyMmlucHV0X2lkcyUyMiUyQyUyMCUyMmxhYmVscyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdGZfdGVzdF9zZXQlMjAlM0QlMjB0b2tlbml6ZWRfYmlsbHN1bSU1QiUyMnRlc3QlMjIlNUQudG9fdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjBjb2x1bW5zJTNEJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlMkMlMjAlMjJpbnB1dF9pZHMlMjIlMkMlMjAlMjJsYWJlbHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = tokenized_billsum[<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>    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 = tokenized_billsum[<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>    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>)`}}),z=new xt({props:{$$slots:{default:[$s]},$$scope:{ctx:S}}}),H=new se({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>)`}}),W=new se({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIydDUtc21hbGwlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-small&quot;</span>)`}}),A=new se({props:{code:"bW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)'}}),ue=new se({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(){s=i("p"),u=n("Para hacer fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),l=i("code"),h=n("tf.data.Dataset"),M=n(" con "),b=i("code"),j=n("to_tf_dataset"),Z=n(". Especifica los inputs y etiquetas en "),_=i("code"),w=n("columns"),G=n(", el tama\xF1o de lote, el data collator, y si es necesario mezclar el dataset:"),B=y(),T(x.$$.fragment),X=y(),T(z.$$.fragment),D=y(),N=i("p"),he=n("Crea la funci\xF3n optimizadora, establece la tasa de aprendizaje y algunos hiperpar\xE1metros de entrenamiento:"),pe=y(),T(H.$$.fragment),L=y(),Q=i("p"),F=n("Carga T5 con "),oe=i("code"),ee=n("TFAutoModelForSeq2SeqLM"),ye=n(":"),O=y(),T(W.$$.fragment),le=y(),K=i("p"),me=n("Configura el modelo para entrenamiento con "),R=i("a"),V=i("code"),Y=n("compile"),d=n(":"),E=y(),T(A.$$.fragment),ge=y(),I=i("p"),fe=n("Llama a "),te=i("a"),P=i("code"),Me=n("fit"),re=n(" para realizar el fine-tuning del modelo:"),ae=y(),T(ue.$$.fragment),this.h()},l(r){s=c(r,"P",{});var $=p(s);u=o($,"Para hacer fine-tuning de un modelo en TensorFlow, comienza por convertir tus datasets al formato "),l=c($,"CODE",{});var ie=p(l);h=o(ie,"tf.data.Dataset"),ie.forEach(a),M=o($," con "),b=c($,"CODE",{});var Re=p(b);j=o(Re,"to_tf_dataset"),Re.forEach(a),Z=o($,". Especifica los inputs y etiquetas en "),_=c($,"CODE",{});var Ee=p(_);w=o(Ee,"columns"),Ee.forEach(a),G=o($,", el tama\xF1o de lote, el data collator, y si es necesario mezclar el dataset:"),$.forEach(a),B=g(r),U(x.$$.fragment,r),X=g(r),U(z.$$.fragment,r),D=g(r),N=c(r,"P",{});var Ve=p(N);he=o(Ve,"Crea la funci\xF3n optimizadora, establece la tasa de aprendizaje y algunos hiperpar\xE1metros de entrenamiento:"),Ve.forEach(a),pe=g(r),U(H.$$.fragment,r),L=g(r),Q=c(r,"P",{});var Te=p(Q);F=o(Te,"Carga T5 con "),oe=c(Te,"CODE",{});var $e=p(oe);ee=o($e,"TFAutoModelForSeq2SeqLM"),$e.forEach(a),ye=o(Te,":"),Te.forEach(a),O=g(r),U(W.$$.fragment,r),le=g(r),K=c(r,"P",{});var Ue=p(K);me=o(Ue,"Configura el modelo para entrenamiento con "),R=c(Ue,"A",{href:!0,rel:!0});var ce=p(R);V=c(ce,"CODE",{});var Ye=p(V);Y=o(Ye,"compile"),Ye.forEach(a),ce.forEach(a),d=o(Ue,":"),Ue.forEach(a),E=g(r),U(A.$$.fragment,r),ge=g(r),I=c(r,"P",{});var je=p(I);fe=o(je,"Llama a "),te=c(je,"A",{href:!0,rel:!0});var De=p(te);P=c(De,"CODE",{});var He=p(P);Me=o(He,"fit"),He.forEach(a),De.forEach(a),re=o(je," para realizar el fine-tuning del modelo:"),je.forEach(a),ae=g(r),U(ue.$$.fragment,r),this.h()},h(){v(R,"href","https://keras.io/api/models/model_training_apis/#compile-method"),v(R,"rel","nofollow"),v(te,"href","https://keras.io/api/models/model_training_apis/#fit-method"),v(te,"rel","nofollow")},m(r,$){m(r,s,$),t(s,u),t(s,l),t(l,h),t(s,M),t(s,b),t(b,j),t(s,Z),t(s,_),t(_,w),t(s,G),m(r,B,$),J(x,r,$),m(r,X,$),J(z,r,$),m(r,D,$),m(r,N,$),t(N,he),m(r,pe,$),J(H,r,$),m(r,L,$),m(r,Q,$),t(Q,F),t(Q,oe),t(oe,ee),t(Q,ye),m(r,O,$),J(W,r,$),m(r,le,$),m(r,K,$),t(K,me),t(K,R),t(R,V),t(V,Y),t(K,d),m(r,E,$),J(A,r,$),m(r,ge,$),m(r,I,$),t(I,fe),t(I,te),t(te,P),t(P,Me),t(I,re),m(r,ae,$),J(ue,r,$),be=!0},p(r,$){const ie={};$&2&&(ie.$$scope={dirty:$,ctx:r}),z.$set(ie)},i(r){be||(k(x.$$.fragment,r),k(z.$$.fragment,r),k(H.$$.fragment,r),k(W.$$.fragment,r),k(A.$$.fragment,r),k(ue.$$.fragment,r),be=!0)},o(r){C(x.$$.fragment,r),C(z.$$.fragment,r),C(H.$$.fragment,r),C(W.$$.fragment,r),C(A.$$.fragment,r),C(ue.$$.fragment,r),be=!1},d(r){r&&a(s),r&&a(B),q(x,r),r&&a(X),q(z,r),r&&a(D),r&&a(N),r&&a(pe),q(H,r),r&&a(L),r&&a(Q),r&&a(O),q(W,r),r&&a(le),r&&a(K),r&&a(E),q(A,r),r&&a(ge),r&&a(I),r&&a(ae),q(ue,r)}}}function vs(S){let s,u;return s=new Xt({props:{$$slots:{default:[js]},$$scope:{ctx:S}}}),{c(){T(s.$$.fragment)},l(l){U(s.$$.fragment,l)},m(l,h){J(s,l,h),u=!0},p(l,h){const M={};h&2&&(M.$$scope={dirty:h,ctx:l}),s.$set(M)},i(l){u||(k(s.$$.fragment,l),u=!0)},o(l){C(s.$$.fragment,l),u=!1},d(l){q(s,l)}}}function ws(S){let s,u,l,h,M,b,j,Z;return{c(){s=i("p"),u=n(`Para un ejemplo con mayor profundidad de c\xF3mo hacer fine-tuning a un modelo para generaci\xF3n de res\xFAmenes, revisa la
`),l=i("a"),h=n("notebook en PyTorch"),M=n(`
o a la `),b=i("a"),j=n("notebook en TensorFlow"),Z=n("."),this.h()},l(_){s=c(_,"P",{});var w=p(s);u=o(w,`Para un ejemplo con mayor profundidad de c\xF3mo hacer fine-tuning a un modelo para generaci\xF3n de res\xFAmenes, revisa la
`),l=c(w,"A",{href:!0,rel:!0});var G=p(l);h=o(G,"notebook en PyTorch"),G.forEach(a),M=o(w,`
o a la `),b=c(w,"A",{href:!0,rel:!0});var B=p(b);j=o(B,"notebook en TensorFlow"),B.forEach(a),Z=o(w,"."),w.forEach(a),this.h()},h(){v(l,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb"),v(l,"rel","nofollow"),v(b,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb"),v(b,"rel","nofollow")},m(_,w){m(_,s,w),t(s,u),t(s,l),t(l,h),t(s,M),t(s,b),t(b,j),t(s,Z)},d(_){_&&a(s)}}}function _s(S){let s,u,l,h,M,b,j,Z,_,w,G,B,x,X,z,D,N,he,pe,H,L,Q,F,oe,ee,ye,O,W,le,K,me,R,V,Y,d,E,A,ge,I,fe,te,P,Me,re,ae,ue,be,r,$,ie,Re,Ee,Ve,Te,$e,Ue,ce,Ye,je,De,He,et,Wt,Nt,$t,Je,Ce,tt,Ae,Vt,at,Yt,jt,ve,Dt,st,Ht,Qt,lt,Pt,Lt,vt,Ie,wt,Qe,Ot,_t,we,nt,Kt,ea,Fe,ta,ot,aa,sa,la,Be,na,rt,oa,ra,Et,xe,Tt,de,ia,it,ca,pa,ct,ma,fa,pt,ua,da,Ut,Xe,Jt,ne,ha,mt,ya,ga,ft,ba,Ma,ut,$a,ja,dt,va,wa,kt,qe,Ct,ke,Ze,ht,We,_a,yt,Ea,qt,Se,Zt,Ge,St;return b=new Bt({}),G=new ms({props:{id:"yHnr5Dk2zCI"}}),R=new xt({props:{$$slots:{default:[fs]},$$scope:{ctx:S}}}),A=new Bt({}),ae=new se({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBYmlsbHN1bSUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJiaWxsc3VtJTIyJTJDJTIwc3BsaXQlM0QlMjJjYV90ZXN0JTIyKQ==",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>billsum = load_dataset(<span class="hljs-string">&quot;billsum&quot;</span>, split=<span class="hljs-string">&quot;ca_test&quot;</span>)`}}),ie=new se({props:{code:"YmlsbHN1bSUyMCUzRCUyMGJpbGxzdW0udHJhaW5fdGVzdF9zcGxpdCh0ZXN0X3NpemUlM0QwLjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>billsum = billsum.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),$e=new se({props:{code:"YmlsbHN1bSU1QiUyMnRyYWluJTIyJTVEJTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>billsum[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;summary&#x27;</span>: <span class="hljs-string">&#x27;Existing law authorizes state agencies to enter into contracts for the acquisition of goods or services upon approval by the Department of General Services. Existing law sets forth various requirements and prohibitions for those contracts, including, but not limited to, a prohibition on entering into contracts for the acquisition of goods or services of $100,000 or more with a contractor that discriminates between spouses and domestic partners or same-sex and different-sex couples in the provision of benefits. Existing law provides that a contract entered into in violation of those requirements and prohibitions is void and authorizes the state or any person acting on behalf of the state to bring a civil action seeking a determination that a contract is in violation and therefore void. Under existing law, a willful violation of those requirements and prohibitions is a misdemeanor.\\nThis bill would also prohibit a state agency from entering into contracts for the acquisition of goods or services of $100,000 or more with a contractor that discriminates between employees on the basis of gender identity in the provision of benefits, as specified. By expanding the scope of a crime, this bill would impose a state-mandated local program.\\nThe California Constitution requires the state to reimburse local agencies and school districts for certain costs mandated by the state. Statutory provisions establish procedures for making that reimbursement.\\nThis bill would provide that no reimbursement is required by this act for a specified reason.&#x27;</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;The people of the State of California do enact as follows:\\n\\n\\nSECTION 1.\\nSection 10295.35 is added to the Public Contract Code, to read:\\n10295.35.\\n(a) (1) Notwithstanding any other law, a state agency shall not enter into any contract for the acquisition of goods or services in the amount of one hundred thousand dollars ($100,000) or more with a contractor that, in the provision of benefits, discriminates between employees on the basis of an employee\u2019s or dependent\u2019s actual or perceived gender identity, including, but not limited to, the employee\u2019s or dependent\u2019s identification as transgender.\\n(2) For purposes of this section, \u201Ccontract\u201D includes contracts with a cumulative amount of one hundred thousand dollars ($100,000) or more per contractor in each fiscal year.\\n(3) For purposes of this section, an employee health plan is discriminatory if the plan is not consistent with Section 1365.5 of the Health and Safety Code and Section 10140 of the Insurance Code.\\n(4) The requirements of this section shall apply only to those portions of a contractor\u2019s operations that occur under any of the following conditions:\\n(A) Within the state.\\n(B) On real property outside the state if the property is owned by the state or if the state has a right to occupy the property, and if the contractor\u2019s presence at that location is connected to a contract with the state.\\n(C) Elsewhere in the United States where work related to a state contract is being performed.\\n(b) Contractors shall treat as confidential, to the maximum extent allowed by law or by the requirement of the contractor\u2019s insurance provider, any request by an employee or applicant for employment benefits or any documentation of eligibility for benefits submitted by an employee or applicant for employment.\\n(c) After taking all reasonable measures to find a contractor that complies with this section, as determined by the state agency, the requirements of this section may be waived under any of the following circumstances:\\n(1) There is only one prospective contractor willing to enter into a specific contract with the state agency.\\n(2) The contract is necessary to respond to an emergency, as determined by the state agency, that endangers the public health, welfare, or safety, or the contract is necessary for the provision of essential services, and no entity that complies with the requirements of this section capable of responding to the emergency is immediately available.\\n(3) The requirements of this section violate, or are inconsistent with, the terms or conditions of a grant, subvention, or agreement, if the agency has made a good faith attempt to change the terms or conditions of any grant, subvention, or agreement to authorize application of this section.\\n(4) The contractor is providing wholesale or bulk water, power, or natural gas, the conveyance or transmission of the same, or ancillary services, as required for ensuring reliable services in accordance with good utility practice, if the purchase of the same cannot practically be accomplished through the standard competitive bidding procedures and the contractor is not providing direct retail services to end users.\\n(d) (1) A contractor shall not be deemed to discriminate in the provision of benefits if the contractor, in providing the benefits, pays the actual costs incurred in obtaining the benefit.\\n(2) If a contractor is unable to provide a certain benefit, despite taking reasonable measures to do so, the contractor shall not be deemed to discriminate in the provision of benefits.\\n(e) (1) Every contract subject to this chapter shall contain a statement by which the contractor certifies that the contractor is in compliance with this section.\\n(2) The department or other contracting agency shall enforce this section pursuant to its existing enforcement powers.\\n(3) (A) If a contractor falsely certifies that it is in compliance with this section, the contract with that contractor shall be subject to Article 9 (commencing with Section 10420), unless, within a time period specified by the department or other contracting agency, the contractor provides to the department or agency proof that it has complied, or is in the process of complying, with this section.\\n(B) The application of the remedies or penalties contained in Article 9 (commencing with Section 10420) to a contract subject to this chapter shall not preclude the application of any existing remedies otherwise available to the department or other contracting agency under its existing enforcement powers.\\n(f) Nothing in this section is intended to regulate the contracting practices of any local jurisdiction.\\n(g) This section shall be construed so as not to conflict with applicable federal laws, rules, or regulations. In the event that a court or agency of competent jurisdiction holds that federal law, rule, or regulation invalidates any clause, sentence, paragraph, or section of this code or the application thereof to any person or circumstances, it is the intent of the state that the court or agency sever that clause, sentence, paragraph, or section so that the remainder of this section shall remain in effect.\\nSEC. 2.\\nSection 10295.35 of the Public Contract Code shall not be construed to create any new enforcement authority or responsibility in the Department of General Services or any other contracting agency.\\nSEC. 3.\\nNo reimbursement is required by this act pursuant to Section 6 of Article XIII\\u2009B of the California Constitution because the only costs that may be incurred by a local agency or school district will be incurred because this act creates a new crime or infraction, eliminates a crime or infraction, or changes the penalty for a crime or infraction, within the meaning of Section 17556 of the Government Code, or changes the definition of a crime within the meaning of Section 6 of Article XIII\\u2009B of the California Constitution.&#x27;</span>,
 <span class="hljs-string">&#x27;title&#x27;</span>: <span class="hljs-string">&#x27;An act to add Section 10295.35 to the Public Contract Code, relating to public contracts.&#x27;</span>}`}}),Ae=new Bt({}),Ie=new se({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ0NS1zbWFsbCUyMik=",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;t5-small&quot;</span>)`}}),xe=new se({props:{code:"cHJlZml4JTIwJTNEJTIwJTIyc3VtbWFyaXplJTNBJTIwJTIyJTBBJTBBJTBBZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBpbnB1dHMlMjAlM0QlMjAlNUJwcmVmaXglMjAlMkIlMjBkb2MlMjBmb3IlMjBkb2MlMjBpbiUyMGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihpbnB1dHMlMkMlMjBtYXhfbGVuZ3RoJTNEMTAyNCUyQyUyMHRydW5jYXRpb24lM0RUcnVlKSUwQSUwQSUyMCUyMCUyMCUyMGxhYmVscyUyMCUzRCUyMHRva2VuaXplcih0ZXh0X3RhcmdldCUzRGV4YW1wbGVzJTVCJTIyc3VtbWFyeSUyMiU1RCUyQyUyMG1heF9sZW5ndGglM0QxMjglMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBtb2RlbF9pbnB1dHMlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjBsYWJlbHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlMEElMjAlMjAlMjAlMjByZXR1cm4lMjBtb2RlbF9pbnB1dHM=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prefix = <span class="hljs-string">&quot;summarize: &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>    inputs = [prefix + doc <span class="hljs-keyword">for</span> doc <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;text&quot;</span>]]
<span class="hljs-meta">... </span>    model_inputs = tokenizer(inputs, max_length=<span class="hljs-number">1024</span>, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    labels = tokenizer(text_target=examples[<span class="hljs-string">&quot;summary&quot;</span>], max_length=<span class="hljs-number">128</span>, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    model_inputs[<span class="hljs-string">&quot;labels&quot;</span>] = labels[<span class="hljs-string">&quot;input_ids&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> model_inputs`}}),Xe=new se({props:{code:"dG9rZW5pemVkX2JpbGxzdW0lMjAlM0QlMjBiaWxsc3VtLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_billsum = billsum.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)'}}),qe=new ls({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ys],pytorch:[ds]},$$scope:{ctx:S}}}),We=new Bt({}),Se=new ls({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[vs],pytorch:[Ms]},$$scope:{ctx:S}}}),Ge=new xt({props:{$$slots:{default:[ws]},$$scope:{ctx:S}}}),{c(){s=i("meta"),u=y(),l=i("h1"),h=i("a"),M=i("span"),T(b.$$.fragment),j=y(),Z=i("span"),_=n("Generaci\xF3n de res\xFAmenes"),w=y(),T(G.$$.fragment),B=y(),x=i("p"),X=n("La generaci\xF3n de res\xFAmenes (summarization, en ingl\xE9s) crea una versi\xF3n m\xE1s corta de un documento o un art\xEDculo que resume toda su informaci\xF3n importante. Junto con la traducci\xF3n, es un ejemplo de una tarea que puede ser formulada como una tarea secuencia a secuencia. La generaci\xF3n de res\xFAmenes puede ser:"),z=y(),D=i("ul"),N=i("li"),he=n("Extractiva: Extrae la informaci\xF3n m\xE1s relevante de un documento."),pe=y(),H=i("li"),L=n("Abstractiva: Genera un texto nuevo que captura la informaci\xF3n m\xE1s importante."),Q=y(),F=i("p"),oe=n("Esta gu\xEDa te mostrar\xE1 c\xF3mo puedes hacer fine-tuning del modelo "),ee=i("a"),ye=n("T5"),O=n(" sobre el subset de proyectos de ley del estado de California, dentro del dataset "),W=i("a"),le=n("BillSum"),K=n(" para hacer generaci\xF3n de res\xFAmenes abstractiva."),me=y(),T(R.$$.fragment),V=y(),Y=i("h2"),d=i("a"),E=i("span"),T(A.$$.fragment),ge=y(),I=i("span"),fe=n("Carga el dataset BillSum"),te=y(),P=i("p"),Me=n("Carga el dataset BillSum de la biblioteca \u{1F917} Datasets:"),re=y(),T(ae.$$.fragment),ue=y(),be=i("p"),r=n("Divide el dataset en un set de train y un set de test:"),$=y(),T(ie.$$.fragment),Re=y(),Ee=i("p"),Ve=n("A continuaci\xF3n, observa un ejemplo:"),Te=y(),T($e.$$.fragment),Ue=y(),ce=i("p"),Ye=n("El campo "),je=i("code"),De=n("text"),He=n(" es el input y el campo "),et=i("code"),Wt=n("summary"),Nt=n(" es el objetivo."),$t=y(),Je=i("h2"),Ce=i("a"),tt=i("span"),T(Ae.$$.fragment),Vt=y(),at=i("span"),Yt=n("Preprocesa"),jt=y(),ve=i("p"),Dt=n("Carga el tokenizador T5 para procesar "),st=i("code"),Ht=n("text"),Qt=n(" y "),lt=i("code"),Pt=n("summary"),Lt=n(":"),vt=y(),T(Ie.$$.fragment),wt=y(),Qe=i("p"),Ot=n("La funci\xF3n de preprocesamiento necesita:"),_t=y(),we=i("ol"),nt=i("li"),Kt=n("Agregar un prefijo al input; una clave para que T5 sepa que se trata de una tarea de generaci\xF3n de res\xFAmenes. Algunos modelos capaces de realizar m\xFAltiples tareas de NLP requieren una clave que indique la tarea espec\xEDfica."),ea=y(),Fe=i("li"),ta=n("Usar el argumento "),ot=i("code"),aa=n("text_target"),sa=n(" para tokenizar etiquetas."),la=y(),Be=i("li"),na=n("Truncar secuencias para que no sean m\xE1s largas que la longitud m\xE1xima fijada por el par\xE1metro "),rt=i("code"),oa=n("max_length"),ra=n("."),Et=y(),T(xe.$$.fragment),Tt=y(),de=i("p"),ia=n("Usa la funci\xF3n "),it=i("code"),ca=n("map"),pa=n(" de \u{1F917} Datasets para aplicar la funci\xF3n de preprocesamiento sobre el dataset en su totalidad. Puedes acelerar la funci\xF3n "),ct=i("code"),ma=n("map"),fa=n(" configurando el argumento "),pt=i("code"),ua=n("batched=True"),da=n(" para procesar m\xFAltiples elementos del dataset a la vez:"),Ut=y(),T(Xe.$$.fragment),Jt=y(),ne=i("p"),ha=n("Usa "),mt=i("code"),ya=n("DataCollatorForSeq2Seq"),ga=n(" para crear un lote de ejemplos. Esto tambi\xE9n "),ft=i("em"),ba=n("rellenar\xE1 din\xE1micamente"),Ma=n(" tu texto y etiquetas a la dimensi\xF3n del elemento m\xE1s largo del lote para que tengan un largo uniforme. Si bien es posible rellenar tu texto en la funci\xF3n "),ut=i("code"),$a=n("tokenizer"),ja=n(" mediante el argumento "),dt=i("code"),va=n("padding=True"),wa=n(", el rellenado din\xE1mico es m\xE1s eficiente."),kt=y(),T(qe.$$.fragment),Ct=y(),ke=i("h2"),Ze=i("a"),ht=i("span"),T(We.$$.fragment),_a=y(),yt=i("span"),Ea=n("Entrenamiento"),qt=y(),T(Se.$$.fragment),Zt=y(),T(Ge.$$.fragment),this.h()},l(e){const f=cs('[data-svelte="svelte-1phssyn"]',document.head);s=c(f,"META",{name:!0,content:!0}),f.forEach(a),u=g(e),l=c(e,"H1",{class:!0});var Ne=p(l);h=c(Ne,"A",{id:!0,class:!0,href:!0});var gt=p(h);M=c(gt,"SPAN",{});var bt=p(M);U(b.$$.fragment,bt),bt.forEach(a),gt.forEach(a),j=g(Ne),Z=c(Ne,"SPAN",{});var Mt=p(Z);_=o(Mt,"Generaci\xF3n de res\xFAmenes"),Mt.forEach(a),Ne.forEach(a),w=g(e),U(G.$$.fragment,e),B=g(e),x=c(e,"P",{});var Ta=p(x);X=o(Ta,"La generaci\xF3n de res\xFAmenes (summarization, en ingl\xE9s) crea una versi\xF3n m\xE1s corta de un documento o un art\xEDculo que resume toda su informaci\xF3n importante. Junto con la traducci\xF3n, es un ejemplo de una tarea que puede ser formulada como una tarea secuencia a secuencia. La generaci\xF3n de res\xFAmenes puede ser:"),Ta.forEach(a),z=g(e),D=c(e,"UL",{});var Gt=p(D);N=c(Gt,"LI",{});var Ua=p(N);he=o(Ua,"Extractiva: Extrae la informaci\xF3n m\xE1s relevante de un documento."),Ua.forEach(a),pe=g(Gt),H=c(Gt,"LI",{});var Ja=p(H);L=o(Ja,"Abstractiva: Genera un texto nuevo que captura la informaci\xF3n m\xE1s importante."),Ja.forEach(a),Gt.forEach(a),Q=g(e),F=c(e,"P",{});var Pe=p(F);oe=o(Pe,"Esta gu\xEDa te mostrar\xE1 c\xF3mo puedes hacer fine-tuning del modelo "),ee=c(Pe,"A",{href:!0,rel:!0});var ka=p(ee);ye=o(ka,"T5"),ka.forEach(a),O=o(Pe," sobre el subset de proyectos de ley del estado de California, dentro del dataset "),W=c(Pe,"A",{href:!0,rel:!0});var Ca=p(W);le=o(Ca,"BillSum"),Ca.forEach(a),K=o(Pe," para hacer generaci\xF3n de res\xFAmenes abstractiva."),Pe.forEach(a),me=g(e),U(R.$$.fragment,e),V=g(e),Y=c(e,"H2",{class:!0});var zt=p(Y);d=c(zt,"A",{id:!0,class:!0,href:!0});var qa=p(d);E=c(qa,"SPAN",{});var Za=p(E);U(A.$$.fragment,Za),Za.forEach(a),qa.forEach(a),ge=g(zt),I=c(zt,"SPAN",{});var Sa=p(I);fe=o(Sa,"Carga el dataset BillSum"),Sa.forEach(a),zt.forEach(a),te=g(e),P=c(e,"P",{});var Ga=p(P);Me=o(Ga,"Carga el dataset BillSum de la biblioteca \u{1F917} Datasets:"),Ga.forEach(a),re=g(e),U(ae.$$.fragment,e),ue=g(e),be=c(e,"P",{});var za=p(be);r=o(za,"Divide el dataset en un set de train y un set de test:"),za.forEach(a),$=g(e),U(ie.$$.fragment,e),Re=g(e),Ee=c(e,"P",{});var Ra=p(Ee);Ve=o(Ra,"A continuaci\xF3n, observa un ejemplo:"),Ra.forEach(a),Te=g(e),U($e.$$.fragment,e),Ue=g(e),ce=c(e,"P",{});var Le=p(ce);Ye=o(Le,"El campo "),je=c(Le,"CODE",{});var Aa=p(je);De=o(Aa,"text"),Aa.forEach(a),He=o(Le," es el input y el campo "),et=c(Le,"CODE",{});var Ia=p(et);Wt=o(Ia,"summary"),Ia.forEach(a),Nt=o(Le," es el objetivo."),Le.forEach(a),$t=g(e),Je=c(e,"H2",{class:!0});var Rt=p(Je);Ce=c(Rt,"A",{id:!0,class:!0,href:!0});var Fa=p(Ce);tt=c(Fa,"SPAN",{});var Ba=p(tt);U(Ae.$$.fragment,Ba),Ba.forEach(a),Fa.forEach(a),Vt=g(Rt),at=c(Rt,"SPAN",{});var xa=p(at);Yt=o(xa,"Preprocesa"),xa.forEach(a),Rt.forEach(a),jt=g(e),ve=c(e,"P",{});var Oe=p(ve);Dt=o(Oe,"Carga el tokenizador T5 para procesar "),st=c(Oe,"CODE",{});var Xa=p(st);Ht=o(Xa,"text"),Xa.forEach(a),Qt=o(Oe," y "),lt=c(Oe,"CODE",{});var Wa=p(lt);Pt=o(Wa,"summary"),Wa.forEach(a),Lt=o(Oe,":"),Oe.forEach(a),vt=g(e),U(Ie.$$.fragment,e),wt=g(e),Qe=c(e,"P",{});var Na=p(Qe);Ot=o(Na,"La funci\xF3n de preprocesamiento necesita:"),Na.forEach(a),_t=g(e),we=c(e,"OL",{});var Ke=p(we);nt=c(Ke,"LI",{});var Va=p(nt);Kt=o(Va,"Agregar un prefijo al input; una clave para que T5 sepa que se trata de una tarea de generaci\xF3n de res\xFAmenes. Algunos modelos capaces de realizar m\xFAltiples tareas de NLP requieren una clave que indique la tarea espec\xEDfica."),Va.forEach(a),ea=g(Ke),Fe=c(Ke,"LI",{});var At=p(Fe);ta=o(At,"Usar el argumento "),ot=c(At,"CODE",{});var Ya=p(ot);aa=o(Ya,"text_target"),Ya.forEach(a),sa=o(At," para tokenizar etiquetas."),At.forEach(a),la=g(Ke),Be=c(Ke,"LI",{});var It=p(Be);na=o(It,"Truncar secuencias para que no sean m\xE1s largas que la longitud m\xE1xima fijada por el par\xE1metro "),rt=c(It,"CODE",{});var Da=p(rt);oa=o(Da,"max_length"),Da.forEach(a),ra=o(It,"."),It.forEach(a),Ke.forEach(a),Et=g(e),U(xe.$$.fragment,e),Tt=g(e),de=c(e,"P",{});var ze=p(de);ia=o(ze,"Usa la funci\xF3n "),it=c(ze,"CODE",{});var Ha=p(it);ca=o(Ha,"map"),Ha.forEach(a),pa=o(ze," de \u{1F917} Datasets para aplicar la funci\xF3n de preprocesamiento sobre el dataset en su totalidad. Puedes acelerar la funci\xF3n "),ct=c(ze,"CODE",{});var Qa=p(ct);ma=o(Qa,"map"),Qa.forEach(a),fa=o(ze," configurando el argumento "),pt=c(ze,"CODE",{});var Pa=p(pt);ua=o(Pa,"batched=True"),Pa.forEach(a),da=o(ze," para procesar m\xFAltiples elementos del dataset a la vez:"),ze.forEach(a),Ut=g(e),U(Xe.$$.fragment,e),Jt=g(e),ne=c(e,"P",{});var _e=p(ne);ha=o(_e,"Usa "),mt=c(_e,"CODE",{});var La=p(mt);ya=o(La,"DataCollatorForSeq2Seq"),La.forEach(a),ga=o(_e," para crear un lote de ejemplos. Esto tambi\xE9n "),ft=c(_e,"EM",{});var Oa=p(ft);ba=o(Oa,"rellenar\xE1 din\xE1micamente"),Oa.forEach(a),Ma=o(_e," tu texto y etiquetas a la dimensi\xF3n del elemento m\xE1s largo del lote para que tengan un largo uniforme. Si bien es posible rellenar tu texto en la funci\xF3n "),ut=c(_e,"CODE",{});var Ka=p(ut);$a=o(Ka,"tokenizer"),Ka.forEach(a),ja=o(_e," mediante el argumento "),dt=c(_e,"CODE",{});var es=p(dt);va=o(es,"padding=True"),es.forEach(a),wa=o(_e,", el rellenado din\xE1mico es m\xE1s eficiente."),_e.forEach(a),kt=g(e),U(qe.$$.fragment,e),Ct=g(e),ke=c(e,"H2",{class:!0});var Ft=p(ke);Ze=c(Ft,"A",{id:!0,class:!0,href:!0});var ts=p(Ze);ht=c(ts,"SPAN",{});var as=p(ht);U(We.$$.fragment,as),as.forEach(a),ts.forEach(a),_a=g(Ft),yt=c(Ft,"SPAN",{});var ss=p(yt);Ea=o(ss,"Entrenamiento"),ss.forEach(a),Ft.forEach(a),qt=g(e),U(Se.$$.fragment,e),Zt=g(e),U(Ge.$$.fragment,e),this.h()},h(){v(s,"name","hf:doc:metadata"),v(s,"content",JSON.stringify(Es)),v(h,"id","generacin-de-resmenes"),v(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"),v(h,"href","#generacin-de-resmenes"),v(l,"class","relative group"),v(ee,"href","https://huggingface.co/t5-small"),v(ee,"rel","nofollow"),v(W,"href","https://huggingface.co/datasets/billsum"),v(W,"rel","nofollow"),v(d,"id","carga-el-dataset-billsum"),v(d,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),v(d,"href","#carga-el-dataset-billsum"),v(Y,"class","relative group"),v(Ce,"id","preprocesa"),v(Ce,"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"),v(Ce,"href","#preprocesa"),v(Je,"class","relative group"),v(Ze,"id","entrenamiento"),v(Ze,"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"),v(Ze,"href","#entrenamiento"),v(ke,"class","relative group")},m(e,f){t(document.head,s),m(e,u,f),m(e,l,f),t(l,h),t(h,M),J(b,M,null),t(l,j),t(l,Z),t(Z,_),m(e,w,f),J(G,e,f),m(e,B,f),m(e,x,f),t(x,X),m(e,z,f),m(e,D,f),t(D,N),t(N,he),t(D,pe),t(D,H),t(H,L),m(e,Q,f),m(e,F,f),t(F,oe),t(F,ee),t(ee,ye),t(F,O),t(F,W),t(W,le),t(F,K),m(e,me,f),J(R,e,f),m(e,V,f),m(e,Y,f),t(Y,d),t(d,E),J(A,E,null),t(Y,ge),t(Y,I),t(I,fe),m(e,te,f),m(e,P,f),t(P,Me),m(e,re,f),J(ae,e,f),m(e,ue,f),m(e,be,f),t(be,r),m(e,$,f),J(ie,e,f),m(e,Re,f),m(e,Ee,f),t(Ee,Ve),m(e,Te,f),J($e,e,f),m(e,Ue,f),m(e,ce,f),t(ce,Ye),t(ce,je),t(je,De),t(ce,He),t(ce,et),t(et,Wt),t(ce,Nt),m(e,$t,f),m(e,Je,f),t(Je,Ce),t(Ce,tt),J(Ae,tt,null),t(Je,Vt),t(Je,at),t(at,Yt),m(e,jt,f),m(e,ve,f),t(ve,Dt),t(ve,st),t(st,Ht),t(ve,Qt),t(ve,lt),t(lt,Pt),t(ve,Lt),m(e,vt,f),J(Ie,e,f),m(e,wt,f),m(e,Qe,f),t(Qe,Ot),m(e,_t,f),m(e,we,f),t(we,nt),t(nt,Kt),t(we,ea),t(we,Fe),t(Fe,ta),t(Fe,ot),t(ot,aa),t(Fe,sa),t(we,la),t(we,Be),t(Be,na),t(Be,rt),t(rt,oa),t(Be,ra),m(e,Et,f),J(xe,e,f),m(e,Tt,f),m(e,de,f),t(de,ia),t(de,it),t(it,ca),t(de,pa),t(de,ct),t(ct,ma),t(de,fa),t(de,pt),t(pt,ua),t(de,da),m(e,Ut,f),J(Xe,e,f),m(e,Jt,f),m(e,ne,f),t(ne,ha),t(ne,mt),t(mt,ya),t(ne,ga),t(ne,ft),t(ft,ba),t(ne,Ma),t(ne,ut),t(ut,$a),t(ne,ja),t(ne,dt),t(dt,va),t(ne,wa),m(e,kt,f),J(qe,e,f),m(e,Ct,f),m(e,ke,f),t(ke,Ze),t(Ze,ht),J(We,ht,null),t(ke,_a),t(ke,yt),t(yt,Ea),m(e,qt,f),J(Se,e,f),m(e,Zt,f),J(Ge,e,f),St=!0},p(e,[f]){const Ne={};f&2&&(Ne.$$scope={dirty:f,ctx:e}),R.$set(Ne);const gt={};f&2&&(gt.$$scope={dirty:f,ctx:e}),qe.$set(gt);const bt={};f&2&&(bt.$$scope={dirty:f,ctx:e}),Se.$set(bt);const Mt={};f&2&&(Mt.$$scope={dirty:f,ctx:e}),Ge.$set(Mt)},i(e){St||(k(b.$$.fragment,e),k(G.$$.fragment,e),k(R.$$.fragment,e),k(A.$$.fragment,e),k(ae.$$.fragment,e),k(ie.$$.fragment,e),k($e.$$.fragment,e),k(Ae.$$.fragment,e),k(Ie.$$.fragment,e),k(xe.$$.fragment,e),k(Xe.$$.fragment,e),k(qe.$$.fragment,e),k(We.$$.fragment,e),k(Se.$$.fragment,e),k(Ge.$$.fragment,e),St=!0)},o(e){C(b.$$.fragment,e),C(G.$$.fragment,e),C(R.$$.fragment,e),C(A.$$.fragment,e),C(ae.$$.fragment,e),C(ie.$$.fragment,e),C($e.$$.fragment,e),C(Ae.$$.fragment,e),C(Ie.$$.fragment,e),C(xe.$$.fragment,e),C(Xe.$$.fragment,e),C(qe.$$.fragment,e),C(We.$$.fragment,e),C(Se.$$.fragment,e),C(Ge.$$.fragment,e),St=!1},d(e){a(s),e&&a(u),e&&a(l),q(b),e&&a(w),q(G,e),e&&a(B),e&&a(x),e&&a(z),e&&a(D),e&&a(Q),e&&a(F),e&&a(me),q(R,e),e&&a(V),e&&a(Y),q(A),e&&a(te),e&&a(P),e&&a(re),q(ae,e),e&&a(ue),e&&a(be),e&&a($),q(ie,e),e&&a(Re),e&&a(Ee),e&&a(Te),q($e,e),e&&a(Ue),e&&a(ce),e&&a($t),e&&a(Je),q(Ae),e&&a(jt),e&&a(ve),e&&a(vt),q(Ie,e),e&&a(wt),e&&a(Qe),e&&a(_t),e&&a(we),e&&a(Et),q(xe,e),e&&a(Tt),e&&a(de),e&&a(Ut),q(Xe,e),e&&a(Jt),e&&a(ne),e&&a(kt),q(qe,e),e&&a(Ct),e&&a(ke),q(We),e&&a(qt),q(Se,e),e&&a(Zt),q(Ge,e)}}}const Es={local:"generacin-de-resmenes",sections:[{local:"carga-el-dataset-billsum",title:"Carga el dataset BillSum"},{local:"preprocesa",title:"Preprocesa"},{local:"entrenamiento",title:"Entrenamiento"}],title:"Generaci\xF3n de res\xFAmenes"};function Ts(S){return ps(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gs extends os{constructor(s){super();rs(this,s,Ts,_s,is,{})}}export{Gs as default,Es as metadata};
