import{S as Er,i as qr,s as Tr,e as r,k as d,w as E,t as s,M as Sr,c as n,d as a,m as _,a as i,x as q,h as o,b as g,G as t,g as m,y as T,q as S,o as A,B as x,v as Ar,L as ws}from"../../chunks/vendor-hf-doc-builder.js";import{T as bs}from"../../chunks/Tip-hf-doc-builder.js";import{Y as xr}from"../../chunks/Youtube-hf-doc-builder.js";import{I as na}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as X}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as zr}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as To,M as la}from"../../chunks/Markdown-hf-doc-builder.js";function Pr(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G,u,v,te,U,ae,W,J,Ee,ce,qe,we,ze,Oe,Pe,Q,De,oe,Te,Ce,Se,me,ye,ue,re,Ae,_e,de,ke,ne,le,b,M,ge,xe,Fe,se,$e,Be,fe,Me,he,ie,Ne,ve,Le,je;return{c(){p=s(`The task illustrated in this tutorial is supported by the following model architectures:

`),f=r("p"),l=r("a"),$=s("BART"),y=s(", "),j=r("a"),P=s("BigBird-Pegasus"),I=s(", "),k=r("a"),F=s("Blenderbot"),C=s(", "),N=r("a"),B=s("BlenderbotSmall"),O=s(", "),D=r("a"),pe=s("Encoder decoder"),V=s(", "),L=r("a"),Z=s("FairSeq Machine-Translation"),Y=s(", "),ee=r("a"),K=s("GPTSAN-japanese"),H=s(", "),G=r("a"),u=s("LED"),v=s(", "),te=r("a"),U=s("LongT5"),ae=s(", "),W=r("a"),J=s("M2M100"),Ee=s(", "),ce=r("a"),qe=s("Marian"),we=s(", "),ze=r("a"),Oe=s("mBART"),Pe=s(", "),Q=r("a"),De=s("MT5"),oe=s(", "),Te=r("a"),Ce=s("MVP"),Se=s(", "),me=r("a"),ye=s("NLLB"),ue=s(", "),re=r("a"),Ae=s("NLLB-MOE"),_e=s(", "),de=r("a"),ke=s("Pegasus"),ne=s(", "),le=r("a"),b=s("PEGASUS-X"),M=s(", "),ge=r("a"),xe=s("PLBart"),Fe=s(", "),se=r("a"),$e=s("ProphetNet"),Be=s(", "),fe=r("a"),Me=s("SwitchTransformers"),he=s(", "),ie=r("a"),Ne=s("T5"),ve=s(", "),Le=r("a"),je=s("XLM-ProphetNet"),this.h()},l(be){p=o(be,`The task illustrated in this tutorial is supported by the following model architectures:

`),f=n(be,"P",{});var w=i(f);l=n(w,"A",{href:!0});var tt=i(l);$=o(tt,"BART"),tt.forEach(a),y=o(w,", "),j=n(w,"A",{href:!0});var He=i(j);P=o(He,"BigBird-Pegasus"),He.forEach(a),I=o(w,", "),k=n(w,"A",{href:!0});var c=i(k);F=o(c,"Blenderbot"),c.forEach(a),C=o(w,", "),N=n(w,"A",{href:!0});var z=i(N);B=o(z,"BlenderbotSmall"),z.forEach(a),O=o(w,", "),D=n(w,"A",{href:!0});var Ie=i(D);pe=o(Ie,"Encoder decoder"),Ie.forEach(a),V=o(w,", "),L=n(w,"A",{href:!0});var Ge=i(L);Z=o(Ge,"FairSeq Machine-Translation"),Ge.forEach(a),Y=o(w,", "),ee=n(w,"A",{href:!0});var Ve=i(ee);K=o(Ve,"GPTSAN-japanese"),Ve.forEach(a),H=o(w,", "),G=n(w,"A",{href:!0});var lt=i(G);u=o(lt,"LED"),lt.forEach(a),v=o(w,", "),te=n(w,"A",{href:!0});var Je=i(te);U=o(Je,"LongT5"),Je.forEach(a),ae=o(w,", "),W=n(w,"A",{href:!0});var Ue=i(W);J=o(Ue,"M2M100"),Ue.forEach(a),Ee=o(w,", "),ce=n(w,"A",{href:!0});var Qe=i(ce);qe=o(Qe,"Marian"),Qe.forEach(a),we=o(w,", "),ze=n(w,"A",{href:!0});var Ye=i(ze);Oe=o(Ye,"mBART"),Ye.forEach(a),Pe=o(w,", "),Q=n(w,"A",{href:!0});var it=i(Q);De=o(it,"MT5"),it.forEach(a),oe=o(w,", "),Te=n(w,"A",{href:!0});var Ke=i(Te);Ce=o(Ke,"MVP"),Ke.forEach(a),Se=o(w,", "),me=n(w,"A",{href:!0});var pt=i(me);ye=o(pt,"NLLB"),pt.forEach(a),ue=o(w,", "),re=n(w,"A",{href:!0});var Re=i(re);Ae=o(Re,"NLLB-MOE"),Re.forEach(a),_e=o(w,", "),de=n(w,"A",{href:!0});var We=i(de);ke=o(We,"Pegasus"),We.forEach(a),ne=o(w,", "),le=n(w,"A",{href:!0});var ct=i(le);b=o(ct,"PEGASUS-X"),ct.forEach(a),M=o(w,", "),ge=n(w,"A",{href:!0});var mt=i(ge);xe=o(mt,"PLBart"),mt.forEach(a),Fe=o(w,", "),se=n(w,"A",{href:!0});var Xe=i(se);$e=o(Xe,"ProphetNet"),Xe.forEach(a),Be=o(w,", "),fe=n(w,"A",{href:!0});var ft=i(fe);Me=o(ft,"SwitchTransformers"),ft.forEach(a),he=o(w,", "),ie=n(w,"A",{href:!0});var ht=i(ie);Ne=o(ht,"T5"),ht.forEach(a),ve=o(w,", "),Le=n(w,"A",{href:!0});var at=i(Le);je=o(at,"XLM-ProphetNet"),at.forEach(a),w.forEach(a),this.h()},h(){g(l,"href","../model_doc/bart"),g(j,"href","../model_doc/bigbird_pegasus"),g(k,"href","../model_doc/blenderbot"),g(N,"href","../model_doc/blenderbot-small"),g(D,"href","../model_doc/encoder-decoder"),g(L,"href","../model_doc/fsmt"),g(ee,"href","../model_doc/gptsan-japanese"),g(G,"href","../model_doc/led"),g(te,"href","../model_doc/longt5"),g(W,"href","../model_doc/m2m_100"),g(ce,"href","../model_doc/marian"),g(ze,"href","../model_doc/mbart"),g(Q,"href","../model_doc/mt5"),g(Te,"href","../model_doc/mvp"),g(me,"href","../model_doc/nllb"),g(re,"href","../model_doc/nllb-moe"),g(de,"href","../model_doc/pegasus"),g(le,"href","../model_doc/pegasus_x"),g(ge,"href","../model_doc/plbart"),g(se,"href","../model_doc/prophetnet"),g(fe,"href","../model_doc/switch_transformers"),g(ie,"href","../model_doc/t5"),g(Le,"href","../model_doc/xlm-prophetnet")},m(be,w){m(be,p,w),m(be,f,w),t(f,l),t(l,$),t(f,y),t(f,j),t(j,P),t(f,I),t(f,k),t(k,F),t(f,C),t(f,N),t(N,B),t(f,O),t(f,D),t(D,pe),t(f,V),t(f,L),t(L,Z),t(f,Y),t(f,ee),t(ee,K),t(f,H),t(f,G),t(G,u),t(f,v),t(f,te),t(te,U),t(f,ae),t(f,W),t(W,J),t(f,Ee),t(f,ce),t(ce,qe),t(f,we),t(f,ze),t(ze,Oe),t(f,Pe),t(f,Q),t(Q,De),t(f,oe),t(f,Te),t(Te,Ce),t(f,Se),t(f,me),t(me,ye),t(f,ue),t(f,re),t(re,Ae),t(f,_e),t(f,de),t(de,ke),t(f,ne),t(f,le),t(le,b),t(f,M),t(f,ge),t(ge,xe),t(f,Fe),t(f,se),t(se,$e),t(f,Be),t(f,fe),t(fe,Me),t(f,he),t(f,ie),t(ie,Ne),t(f,ve),t(f,Le),t(Le,je)},d(be){be&&a(p),be&&a(f)}}}function Cr(R){let p,f;return p=new X({props:{code:`from transformers import DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=checkpoint)`,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=checkpoint)`}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p:ws,i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Fr(R){let p,f;return p=new la({props:{$$slots:{default:[Cr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Mr(R){let p,f;return p=new X({props:{code:`from transformers import DataCollatorForSeq2Seq

data_collator = DataCollatorForSeq2Seq(tokenizer=tokenizer, model=checkpoint, return_tensors="tf")`,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=checkpoint, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p:ws,i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Lr(R){let p,f;return p=new la({props:{$$slots:{default:[Mr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Dr(R){let p,f,l,$,y,j,P,I;return{c(){p=r("p"),f=s("If you aren\u2019t familiar with finetuning a model with the "),l=r("a"),$=s("Trainer"),y=s(", take a look at the basic tutorial "),j=r("a"),P=s("here"),I=s("!"),this.h()},l(k){p=n(k,"P",{});var F=i(p);f=o(F,"If you aren\u2019t familiar with finetuning a model with the "),l=n(F,"A",{href:!0});var C=i(l);$=o(C,"Trainer"),C.forEach(a),y=o(F,", take a look at the basic tutorial "),j=n(F,"A",{href:!0});var N=i(j);P=o(N,"here"),N.forEach(a),I=o(F,"!"),F.forEach(a),this.h()},h(){g(l,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Trainer"),g(j,"href","../training#train-with-pytorch-trainer")},m(k,F){m(k,p,F),t(p,f),t(p,l),t(l,$),t(p,y),t(p,j),t(j,P),t(p,I)},d(k){k&&a(p)}}}function Ir(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G,u,v,te,U,ae,W,J,Ee,ce,qe,we,ze,Oe,Pe,Q,De,oe,Te,Ce,Se,me,ye,ue,re,Ae,_e,de,ke,ne,le;return p=new bs({props:{$$slots:{default:[Dr]},$$scope:{ctx:R}}}),k=new X({props:{code:`from transformers import AutoModelForSeq2SeqLM, Seq2SeqTrainingArguments, Seq2SeqTrainer

model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)`,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(checkpoint)`}}),me=new X({props:{code:`training_args = Seq2SeqTrainingArguments(
    output_dir="my_awesome_billsum_model",
    evaluation_strategy="epoch",
    learning_rate=2e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    weight_decay=0.01,
    save_total_limit=3,
    num_train_epochs=4,
    predict_with_generate=True,
    fp16=True,
    push_to_hub=True,
)

trainer = Seq2SeqTrainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_billsum["train"],
    eval_dataset=tokenized_billsum["test"],
    tokenizer=tokenizer,
    data_collator=data_collator,
    compute_metrics=compute_metrics,
)

trainer.train()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = Seq2SeqTrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_billsum_model&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">4</span>,
<span class="hljs-meta">... </span>    predict_with_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    fp16=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    push_to_hub=<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>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),ne=new X({props:{code:"trainer.push_to_hub()",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()'}}),{c(){E(p.$$.fragment),f=d(),l=r("p"),$=s("You\u2019re ready to start training your model now! Load T5 with "),y=r("a"),j=s("AutoModelForSeq2SeqLM"),P=s(":"),I=d(),E(k.$$.fragment),F=d(),C=r("p"),N=s("At this point, only three steps remain:"),B=d(),O=r("ol"),D=r("li"),pe=s("Define your training hyperparameters in "),V=r("a"),L=s("Seq2SeqTrainingArguments"),Z=s(". The only required parameter is "),Y=r("code"),ee=s("output_dir"),K=s(" which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),H=r("code"),G=s("push_to_hub=True"),u=s(" (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),v=r("a"),te=s("Trainer"),U=s(" will evaluate the ROUGE metric and save the training checkpoint."),ae=d(),W=r("li"),J=s("Pass the training arguments to "),Ee=r("a"),ce=s("Seq2SeqTrainer"),qe=s(" along with the model, dataset, tokenizer, data collator, and "),we=r("code"),ze=s("compute_metrics"),Oe=s(" function."),Pe=d(),Q=r("li"),De=s("Call "),oe=r("a"),Te=s("train()"),Ce=s(" to finetune your model."),Se=d(),E(me.$$.fragment),ye=d(),ue=r("p"),re=s("Once training is completed, share your model to the Hub with the "),Ae=r("a"),_e=s("push_to_hub()"),de=s(" method so everyone can use your model:"),ke=d(),E(ne.$$.fragment),this.h()},l(b){q(p.$$.fragment,b),f=_(b),l=n(b,"P",{});var M=i(l);$=o(M,"You\u2019re ready to start training your model now! Load T5 with "),y=n(M,"A",{href:!0});var ge=i(y);j=o(ge,"AutoModelForSeq2SeqLM"),ge.forEach(a),P=o(M,":"),M.forEach(a),I=_(b),q(k.$$.fragment,b),F=_(b),C=n(b,"P",{});var xe=i(C);N=o(xe,"At this point, only three steps remain:"),xe.forEach(a),B=_(b),O=n(b,"OL",{});var Fe=i(O);D=n(Fe,"LI",{});var se=i(D);pe=o(se,"Define your training hyperparameters in "),V=n(se,"A",{href:!0});var $e=i(V);L=o($e,"Seq2SeqTrainingArguments"),$e.forEach(a),Z=o(se,". The only required parameter is "),Y=n(se,"CODE",{});var Be=i(Y);ee=o(Be,"output_dir"),Be.forEach(a),K=o(se," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),H=n(se,"CODE",{});var fe=i(H);G=o(fe,"push_to_hub=True"),fe.forEach(a),u=o(se," (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the "),v=n(se,"A",{href:!0});var Me=i(v);te=o(Me,"Trainer"),Me.forEach(a),U=o(se," will evaluate the ROUGE metric and save the training checkpoint."),se.forEach(a),ae=_(Fe),W=n(Fe,"LI",{});var he=i(W);J=o(he,"Pass the training arguments to "),Ee=n(he,"A",{href:!0});var ie=i(Ee);ce=o(ie,"Seq2SeqTrainer"),ie.forEach(a),qe=o(he," along with the model, dataset, tokenizer, data collator, and "),we=n(he,"CODE",{});var Ne=i(we);ze=o(Ne,"compute_metrics"),Ne.forEach(a),Oe=o(he," function."),he.forEach(a),Pe=_(Fe),Q=n(Fe,"LI",{});var ve=i(Q);De=o(ve,"Call "),oe=n(ve,"A",{href:!0});var Le=i(oe);Te=o(Le,"train()"),Le.forEach(a),Ce=o(ve," to finetune your model."),ve.forEach(a),Fe.forEach(a),Se=_(b),q(me.$$.fragment,b),ye=_(b),ue=n(b,"P",{});var je=i(ue);re=o(je,"Once training is completed, share your model to the Hub with the "),Ae=n(je,"A",{href:!0});var be=i(Ae);_e=o(be,"push_to_hub()"),be.forEach(a),de=o(je," method so everyone can use your model:"),je.forEach(a),ke=_(b),q(ne.$$.fragment,b),this.h()},h(){g(y,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM"),g(V,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Seq2SeqTrainingArguments"),g(v,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Trainer"),g(Ee,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Seq2SeqTrainer"),g(oe,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Trainer.train"),g(Ae,"href","/docs/transformers/v4.29.0/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(b,M){T(p,b,M),m(b,f,M),m(b,l,M),t(l,$),t(l,y),t(y,j),t(l,P),m(b,I,M),T(k,b,M),m(b,F,M),m(b,C,M),t(C,N),m(b,B,M),m(b,O,M),t(O,D),t(D,pe),t(D,V),t(V,L),t(D,Z),t(D,Y),t(Y,ee),t(D,K),t(D,H),t(H,G),t(D,u),t(D,v),t(v,te),t(D,U),t(O,ae),t(O,W),t(W,J),t(W,Ee),t(Ee,ce),t(W,qe),t(W,we),t(we,ze),t(W,Oe),t(O,Pe),t(O,Q),t(Q,De),t(Q,oe),t(oe,Te),t(Q,Ce),m(b,Se,M),T(me,b,M),m(b,ye,M),m(b,ue,M),t(ue,re),t(ue,Ae),t(Ae,_e),t(ue,de),m(b,ke,M),T(ne,b,M),le=!0},p(b,M){const ge={};M&2&&(ge.$$scope={dirty:M,ctx:b}),p.$set(ge)},i(b){le||(S(p.$$.fragment,b),S(k.$$.fragment,b),S(me.$$.fragment,b),S(ne.$$.fragment,b),le=!0)},o(b){A(p.$$.fragment,b),A(k.$$.fragment,b),A(me.$$.fragment,b),A(ne.$$.fragment,b),le=!1},d(b){x(p,b),b&&a(f),b&&a(l),b&&a(I),x(k,b),b&&a(F),b&&a(C),b&&a(B),b&&a(O),b&&a(Se),x(me,b),b&&a(ye),b&&a(ue),b&&a(ke),x(ne,b)}}}function Or(R){let p,f;return p=new la({props:{$$slots:{default:[Ir]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Br(R){let p,f,l,$,y;return{c(){p=r("p"),f=s("If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),l=r("a"),$=s("here"),y=s("!"),this.h()},l(j){p=n(j,"P",{});var P=i(p);f=o(P,"If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),l=n(P,"A",{href:!0});var I=i(l);$=o(I,"here"),I.forEach(a),y=o(P,"!"),P.forEach(a),this.h()},h(){g(l,"href","../training#train-a-tensorflow-model-with-keras")},m(j,P){m(j,p,P),t(p,f),t(p,l),t(l,$),t(p,y)},d(j){j&&a(p)}}}function Nr(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G,u,v,te,U,ae,W,J,Ee,ce,qe,we,ze,Oe,Pe,Q,De,oe,Te,Ce,Se,me,ye,ue,re,Ae,_e,de,ke,ne,le,b,M,ge,xe,Fe,se,$e,Be,fe,Me,he,ie,Ne,ve,Le,je,be,w,tt,He;return p=new bs({props:{$$slots:{default:[Br]},$$scope:{ctx:R}}}),l=new X({props:{code:`from transformers import create_optimizer, AdamWeightDecay

optimizer = AdamWeightDecay(learning_rate=2e-5, weight_decay_rate=0.01)`,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>)`}}),C=new X({props:{code:`from transformers import TFAutoModelForSeq2SeqLM

model = TFAutoModelForSeq2SeqLM.from_pretrained(checkpoint)`,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(checkpoint)`}}),K=new X({props:{code:`tf_train_set = model.prepare_tf_dataset(
    tokenized_billsum["train"],
    shuffle=True,
    batch_size=16,
    collate_fn=data_collator,
)

tf_test_set = model.prepare_tf_dataset(
    tokenized_billsum["test"],
    shuffle=False,
    batch_size=16,
    collate_fn=data_collator,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_billsum[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<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 = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_billsum[<span class="hljs-string">&quot;test&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>)`}}),J=new X({props:{code:`import tensorflow as tf

model.compile(optimizer=optimizer)`,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)`}}),re=new X({props:{code:`from transformers.keras_callbacks import KerasMetricCallback

metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> KerasMetricCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>metric_callback = KerasMetricCallback(metric_fn=compute_metrics, eval_dataset=tf_validation_set)`}}),M=new X({props:{code:`from transformers.keras_callbacks import PushToHubCallback

push_to_hub_callback = PushToHubCallback(
    output_dir="my_awesome_billsum_model",
    tokenizer=tokenizer,
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback

<span class="hljs-meta">&gt;&gt;&gt; </span>push_to_hub_callback = PushToHubCallback(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;my_awesome_billsum_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`}}),$e=new X({props:{code:"callbacks = [metric_callback, push_to_hub_callback]",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]'}}),je=new X({props:{code:"model.fit(x=tf_train_set, validation_data=tf_test_set, epochs=3, callbacks=callbacks)",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>, callbacks=callbacks)'}}),{c(){E(p.$$.fragment),f=s(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),E(l.$$.fragment),$=d(),y=r("p"),j=s("Then you can load T5 with "),P=r("a"),I=s("TFAutoModelForSeq2SeqLM"),k=s(":"),F=d(),E(C.$$.fragment),N=d(),B=r("p"),O=s("Convert your datasets to the "),D=r("code"),pe=s("tf.data.Dataset"),V=s(" format with "),L=r("a"),Z=s("prepare_tf_dataset()"),Y=s(":"),ee=d(),E(K.$$.fragment),H=d(),G=r("p"),u=s("Configure the model for training with "),v=r("a"),te=r("code"),U=s("compile"),ae=s(":"),W=d(),E(J.$$.fragment),Ee=d(),ce=r("p"),qe=s("The last two things to setup before you start training is to compute the ROUGE score from the predictions, and provide a way to push your model to the Hub. Both are done by using "),we=r("a"),ze=s("Keras callbacks"),Oe=s("."),Pe=d(),Q=r("p"),De=s("Pass your "),oe=r("code"),Te=s("compute_metrics"),Ce=s(" function to "),Se=r("a"),me=s("KerasMetricCallback"),ye=s(":"),ue=d(),E(re.$$.fragment),Ae=d(),_e=r("p"),de=s("Specify where to push your model and tokenizer in the "),ke=r("a"),ne=s("PushToHubCallback"),le=s(":"),b=d(),E(M.$$.fragment),ge=d(),xe=r("p"),Fe=s("Then bundle your callbacks together:"),se=d(),E($e.$$.fragment),Be=d(),fe=r("p"),Me=s("Finally, you\u2019re ready to start training your model! Call "),he=r("a"),ie=r("code"),Ne=s("fit"),ve=s(" with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),Le=d(),E(je.$$.fragment),be=d(),w=r("p"),tt=s("Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!"),this.h()},l(c){q(p.$$.fragment,c),f=o(c,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),q(l.$$.fragment,c),$=_(c),y=n(c,"P",{});var z=i(y);j=o(z,"Then you can load T5 with "),P=n(z,"A",{href:!0});var Ie=i(P);I=o(Ie,"TFAutoModelForSeq2SeqLM"),Ie.forEach(a),k=o(z,":"),z.forEach(a),F=_(c),q(C.$$.fragment,c),N=_(c),B=n(c,"P",{});var Ge=i(B);O=o(Ge,"Convert your datasets to the "),D=n(Ge,"CODE",{});var Ve=i(D);pe=o(Ve,"tf.data.Dataset"),Ve.forEach(a),V=o(Ge," format with "),L=n(Ge,"A",{href:!0});var lt=i(L);Z=o(lt,"prepare_tf_dataset()"),lt.forEach(a),Y=o(Ge,":"),Ge.forEach(a),ee=_(c),q(K.$$.fragment,c),H=_(c),G=n(c,"P",{});var Je=i(G);u=o(Je,"Configure the model for training with "),v=n(Je,"A",{href:!0,rel:!0});var Ue=i(v);te=n(Ue,"CODE",{});var Qe=i(te);U=o(Qe,"compile"),Qe.forEach(a),Ue.forEach(a),ae=o(Je,":"),Je.forEach(a),W=_(c),q(J.$$.fragment,c),Ee=_(c),ce=n(c,"P",{});var Ye=i(ce);qe=o(Ye,"The last two things to setup before you start training is to compute the ROUGE score from the predictions, and provide a way to push your model to the Hub. Both are done by using "),we=n(Ye,"A",{href:!0});var it=i(we);ze=o(it,"Keras callbacks"),it.forEach(a),Oe=o(Ye,"."),Ye.forEach(a),Pe=_(c),Q=n(c,"P",{});var Ke=i(Q);De=o(Ke,"Pass your "),oe=n(Ke,"CODE",{});var pt=i(oe);Te=o(pt,"compute_metrics"),pt.forEach(a),Ce=o(Ke," function to "),Se=n(Ke,"A",{href:!0});var Re=i(Se);me=o(Re,"KerasMetricCallback"),Re.forEach(a),ye=o(Ke,":"),Ke.forEach(a),ue=_(c),q(re.$$.fragment,c),Ae=_(c),_e=n(c,"P",{});var We=i(_e);de=o(We,"Specify where to push your model and tokenizer in the "),ke=n(We,"A",{href:!0});var ct=i(ke);ne=o(ct,"PushToHubCallback"),ct.forEach(a),le=o(We,":"),We.forEach(a),b=_(c),q(M.$$.fragment,c),ge=_(c),xe=n(c,"P",{});var mt=i(xe);Fe=o(mt,"Then bundle your callbacks together:"),mt.forEach(a),se=_(c),q($e.$$.fragment,c),Be=_(c),fe=n(c,"P",{});var Xe=i(fe);Me=o(Xe,"Finally, you\u2019re ready to start training your model! Call "),he=n(Xe,"A",{href:!0,rel:!0});var ft=i(he);ie=n(ft,"CODE",{});var ht=i(ie);Ne=o(ht,"fit"),ht.forEach(a),ft.forEach(a),ve=o(Xe," with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),Xe.forEach(a),Le=_(c),q(je.$$.fragment,c),be=_(c),w=n(c,"P",{});var at=i(w);tt=o(at,"Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!"),at.forEach(a),this.h()},h(){g(P,"href","/docs/transformers/v4.29.0/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM"),g(L,"href","/docs/transformers/v4.29.0/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset"),g(v,"href","https://keras.io/api/models/model_training_apis/#compile-method"),g(v,"rel","nofollow"),g(we,"href","../main_classes/keras_callbacks"),g(Se,"href","/docs/transformers/v4.29.0/en/main_classes/keras_callbacks#transformers.KerasMetricCallback"),g(ke,"href","/docs/transformers/v4.29.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback"),g(he,"href","https://keras.io/api/models/model_training_apis/#fit-method"),g(he,"rel","nofollow")},m(c,z){T(p,c,z),m(c,f,z),T(l,c,z),m(c,$,z),m(c,y,z),t(y,j),t(y,P),t(P,I),t(y,k),m(c,F,z),T(C,c,z),m(c,N,z),m(c,B,z),t(B,O),t(B,D),t(D,pe),t(B,V),t(B,L),t(L,Z),t(B,Y),m(c,ee,z),T(K,c,z),m(c,H,z),m(c,G,z),t(G,u),t(G,v),t(v,te),t(te,U),t(G,ae),m(c,W,z),T(J,c,z),m(c,Ee,z),m(c,ce,z),t(ce,qe),t(ce,we),t(we,ze),t(ce,Oe),m(c,Pe,z),m(c,Q,z),t(Q,De),t(Q,oe),t(oe,Te),t(Q,Ce),t(Q,Se),t(Se,me),t(Q,ye),m(c,ue,z),T(re,c,z),m(c,Ae,z),m(c,_e,z),t(_e,de),t(_e,ke),t(ke,ne),t(_e,le),m(c,b,z),T(M,c,z),m(c,ge,z),m(c,xe,z),t(xe,Fe),m(c,se,z),T($e,c,z),m(c,Be,z),m(c,fe,z),t(fe,Me),t(fe,he),t(he,ie),t(ie,Ne),t(fe,ve),m(c,Le,z),T(je,c,z),m(c,be,z),m(c,w,z),t(w,tt),He=!0},p(c,z){const Ie={};z&2&&(Ie.$$scope={dirty:z,ctx:c}),p.$set(Ie)},i(c){He||(S(p.$$.fragment,c),S(l.$$.fragment,c),S(C.$$.fragment,c),S(K.$$.fragment,c),S(J.$$.fragment,c),S(re.$$.fragment,c),S(M.$$.fragment,c),S($e.$$.fragment,c),S(je.$$.fragment,c),He=!0)},o(c){A(p.$$.fragment,c),A(l.$$.fragment,c),A(C.$$.fragment,c),A(K.$$.fragment,c),A(J.$$.fragment,c),A(re.$$.fragment,c),A(M.$$.fragment,c),A($e.$$.fragment,c),A(je.$$.fragment,c),He=!1},d(c){x(p,c),c&&a(f),x(l,c),c&&a($),c&&a(y),c&&a(F),x(C,c),c&&a(N),c&&a(B),c&&a(ee),x(K,c),c&&a(H),c&&a(G),c&&a(W),x(J,c),c&&a(Ee),c&&a(ce),c&&a(Pe),c&&a(Q),c&&a(ue),x(re,c),c&&a(Ae),c&&a(_e),c&&a(b),x(M,c),c&&a(ge),c&&a(xe),c&&a(se),x($e,c),c&&a(Be),c&&a(fe),c&&a(Le),x(je,c),c&&a(be),c&&a(w)}}}function Hr(R){let p,f;return p=new la({props:{$$slots:{default:[Nr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Gr(R){let p,f,l,$,y,j,P,I;return{c(){p=r("p"),f=s(`For a more in-depth example of how to finetune a model for summarization, take a look at the corresponding
`),l=r("a"),$=s("PyTorch notebook"),y=s(`
or `),j=r("a"),P=s("TensorFlow notebook"),I=s("."),this.h()},l(k){p=n(k,"P",{});var F=i(p);f=o(F,`For a more in-depth example of how to finetune a model for summarization, take a look at the corresponding
`),l=n(F,"A",{href:!0,rel:!0});var C=i(l);$=o(C,"PyTorch notebook"),C.forEach(a),y=o(F,`
or `),j=n(F,"A",{href:!0,rel:!0});var N=i(j);P=o(N,"TensorFlow notebook"),N.forEach(a),I=o(F,"."),F.forEach(a),this.h()},h(){g(l,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb"),g(l,"rel","nofollow"),g(j,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb"),g(j,"rel","nofollow")},m(k,F){m(k,p,F),t(p,f),t(p,l),t(l,$),t(p,y),t(p,j),t(j,P),t(p,I)},d(k){k&&a(p)}}}function Ur(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G;return P=new X({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("stevhliu/my_awesome_billsum_model")
inputs = tokenizer(text, return_tensors="pt").input_ids`,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;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids`}}),L=new X({props:{code:`from transformers import AutoModelForSeq2SeqLM

model = AutoModelForSeq2SeqLM.from_pretrained("stevhliu/my_awesome_billsum_model")
outputs = model.generate(inputs, max_new_tokens=100, do_sample=False)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">False</span>)`}}),H=new X({props:{code:"tokenizer.decode(outputs[0], skip_special_tokens=True)",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;the inflation reduction act lowers prescription drug costs, health care costs, and energy costs. it&#x27;</span>s the most aggressive action on tackling the climate crisis <span class="hljs-keyword">in</span> american history. it will ask the ultra-wealthy <span class="hljs-keyword">and</span> corporations to pay their fair share.<span class="hljs-string">&#x27;</span>`}}),{c(){p=r("p"),f=s("Tokenize the text and return the "),l=r("code"),$=s("input_ids"),y=s(" as PyTorch tensors:"),j=d(),E(P.$$.fragment),I=d(),k=r("p"),F=s("Use the "),C=r("a"),N=s("generate()"),B=s(" method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the "),O=r("a"),D=s("Text Generation"),pe=s(" API."),V=d(),E(L.$$.fragment),Z=d(),Y=r("p"),ee=s("Decode the generated token ids back into text:"),K=d(),E(H.$$.fragment),this.h()},l(u){p=n(u,"P",{});var v=i(p);f=o(v,"Tokenize the text and return the "),l=n(v,"CODE",{});var te=i(l);$=o(te,"input_ids"),te.forEach(a),y=o(v," as PyTorch tensors:"),v.forEach(a),j=_(u),q(P.$$.fragment,u),I=_(u),k=n(u,"P",{});var U=i(k);F=o(U,"Use the "),C=n(U,"A",{href:!0});var ae=i(C);N=o(ae,"generate()"),ae.forEach(a),B=o(U," method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the "),O=n(U,"A",{href:!0});var W=i(O);D=o(W,"Text Generation"),W.forEach(a),pe=o(U," API."),U.forEach(a),V=_(u),q(L.$$.fragment,u),Z=_(u),Y=n(u,"P",{});var J=i(Y);ee=o(J,"Decode the generated token ids back into text:"),J.forEach(a),K=_(u),q(H.$$.fragment,u),this.h()},h(){g(C,"href","/docs/transformers/v4.29.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),g(O,"href","../main_classes/text_generation")},m(u,v){m(u,p,v),t(p,f),t(p,l),t(l,$),t(p,y),m(u,j,v),T(P,u,v),m(u,I,v),m(u,k,v),t(k,F),t(k,C),t(C,N),t(k,B),t(k,O),t(O,D),t(k,pe),m(u,V,v),T(L,u,v),m(u,Z,v),m(u,Y,v),t(Y,ee),m(u,K,v),T(H,u,v),G=!0},p:ws,i(u){G||(S(P.$$.fragment,u),S(L.$$.fragment,u),S(H.$$.fragment,u),G=!0)},o(u){A(P.$$.fragment,u),A(L.$$.fragment,u),A(H.$$.fragment,u),G=!1},d(u){u&&a(p),u&&a(j),x(P,u),u&&a(I),u&&a(k),u&&a(V),x(L,u),u&&a(Z),u&&a(Y),u&&a(K),x(H,u)}}}function Rr(R){let p,f;return p=new la({props:{$$slots:{default:[Ur]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Yr(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G;return P=new X({props:{code:`from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("stevhliu/my_awesome_billsum_model")
inputs = tokenizer(text, return_tensors="tf").input_ids`,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;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>).input_ids`}}),L=new X({props:{code:`from transformers import TFAutoModelForSeq2SeqLM

model = TFAutoModelForSeq2SeqLM.from_pretrained("stevhliu/my_awesome_billsum_model")
outputs = model.generate(inputs, max_new_tokens=100, do_sample=False)`,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;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">100</span>, do_sample=<span class="hljs-literal">False</span>)`}}),H=new X({props:{code:"tokenizer.decode(outputs[0], skip_special_tokens=True)",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;the inflation reduction act lowers prescription drug costs, health care costs, and energy costs. it&#x27;</span>s the most aggressive action on tackling the climate crisis <span class="hljs-keyword">in</span> american history. it will ask the ultra-wealthy <span class="hljs-keyword">and</span> corporations to pay their fair share.<span class="hljs-string">&#x27;</span>`}}),{c(){p=r("p"),f=s("Tokenize the text and return the "),l=r("code"),$=s("input_ids"),y=s(" as TensorFlow tensors:"),j=d(),E(P.$$.fragment),I=d(),k=r("p"),F=s("Use the "),C=r("a"),N=s("generate()"),B=s(" method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the "),O=r("a"),D=s("Text Generation"),pe=s(" API."),V=d(),E(L.$$.fragment),Z=d(),Y=r("p"),ee=s("Decode the generated token ids back into text:"),K=d(),E(H.$$.fragment),this.h()},l(u){p=n(u,"P",{});var v=i(p);f=o(v,"Tokenize the text and return the "),l=n(v,"CODE",{});var te=i(l);$=o(te,"input_ids"),te.forEach(a),y=o(v," as TensorFlow tensors:"),v.forEach(a),j=_(u),q(P.$$.fragment,u),I=_(u),k=n(u,"P",{});var U=i(k);F=o(U,"Use the "),C=n(U,"A",{href:!0});var ae=i(C);N=o(ae,"generate()"),ae.forEach(a),B=o(U," method to create the summarization. For more details about the different text generation strategies and parameters for controlling generation, check out the "),O=n(U,"A",{href:!0});var W=i(O);D=o(W,"Text Generation"),W.forEach(a),pe=o(U," API."),U.forEach(a),V=_(u),q(L.$$.fragment,u),Z=_(u),Y=n(u,"P",{});var J=i(Y);ee=o(J,"Decode the generated token ids back into text:"),J.forEach(a),K=_(u),q(H.$$.fragment,u),this.h()},h(){g(C,"href","/docs/transformers/v4.29.0/en/main_classes/text_generation#transformers.TFGenerationMixin.generate"),g(O,"href","../main_classes/text_generation")},m(u,v){m(u,p,v),t(p,f),t(p,l),t(l,$),t(p,y),m(u,j,v),T(P,u,v),m(u,I,v),m(u,k,v),t(k,F),t(k,C),t(C,N),t(k,B),t(k,O),t(O,D),t(k,pe),m(u,V,v),T(L,u,v),m(u,Z,v),m(u,Y,v),t(Y,ee),m(u,K,v),T(H,u,v),G=!0},p:ws,i(u){G||(S(P.$$.fragment,u),S(L.$$.fragment,u),S(H.$$.fragment,u),G=!0)},o(u){A(P.$$.fragment,u),A(L.$$.fragment,u),A(H.$$.fragment,u),G=!1},d(u){u&&a(p),u&&a(j),x(P,u),u&&a(I),u&&a(k),u&&a(V),x(L,u),u&&a(Z),u&&a(Y),u&&a(K),x(H,u)}}}function Kr(R){let p,f;return p=new la({props:{$$slots:{default:[Yr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(l){q(p.$$.fragment,l)},m(l,$){T(p,l,$),f=!0},p(l,$){const y={};$&2&&(y.$$scope={dirty:$,ctx:l}),p.$set(y)},i(l){f||(S(p.$$.fragment,l),f=!0)},o(l){A(p.$$.fragment,l),f=!1},d(l){x(p,l)}}}function Wr(R){let p,f,l,$,y,j,P,I,k,F,C,N,B,O,D,pe,V,L,Z,Y,ee,K,H,G,u,v,te,U,ae,W,J,Ee,ce,qe,we,ze,Oe,Pe,Q,De,oe,Te,Ce,Se,me,ye,ue,re,Ae,_e,de,ke,ne,le,b,M,ge,xe,Fe,se,$e,Be,fe,Me,he,ie,Ne,ve,Le,je,be,w,tt,He,c,z,Ie,Ge,Ve,lt,Je,Ue,Qe,Ye,it,Ke,pt,Re,We,ct,mt,Xe,ft,ht,at,ut,$t,ia,zt,ys,pa,ks,Pa,st,vs,ca,js,Es,ma,qs,Ts,Ca,Pt,Fa,Vt,Ss,Ma,ot,fa,As,xs,Ct,zs,ha,Ps,Cs,Fs,Ft,Ms,ua,Ls,Ds,La,Mt,Da,Ze,Is,Lt,Os,Bs,da,Ns,Hs,_a,Gs,Us,Ia,Dt,Oa,rt,Rs,Jt,Ys,Ks,ga,Ws,Xs,Ba,bt,Na,dt,wt,$a,It,Vs,ba,Js,Ha,et,Qs,Ot,Zs,eo,Bt,to,ao,Nt,so,oo,Ga,Ht,Ua,yt,ro,Gt,no,lo,Ra,Ut,Ya,kt,io,wa,po,co,Ka,_t,vt,ya,Rt,mo,ka,fo,Wa,jt,Xa,Et,Va,gt,qt,va,Yt,ho,ja,uo,Ja,Qt,_o,Qa,Zt,go,Za,Kt,es,nt,$o,ea,bo,wo,Ea,yo,ko,ts,Wt,as,Tt,vo,qa,jo,Eo,ss,St,os;return j=new na({}),C=new zr({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/summarization.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/summarization.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/summarization.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/summarization.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/summarization.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/summarization.ipynb"}]}}),B=new xr({props:{id:"yHnr5Dk2zCI"}}),oe=new bs({props:{$$slots:{default:[Pr]},$$scope:{ctx:R}}}),ye=new X({props:{code:"pip install transformers datasets evaluate rouge_score",highlighted:"pip install transformers datasets evaluate rouge_score"}}),de=new X({props:{code:`from huggingface_hub import notebook_login

notebook_login()`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_login()`}}),M=new na({}),Me=new X({props:{code:`from datasets import load_dataset

billsum = load_dataset("billsum", split="ca_test")`,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>)`}}),w=new X({props:{code:"billsum = billsum.train_test_split(test_size=0.2)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>billsum = billsum.train_test_split(test_size=<span class="hljs-number">0.2</span>)'}}),Ie=new X({props:{code:'billsum["train"][0]',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>}`}}),zt=new na({}),Pt=new X({props:{code:`from transformers import AutoTokenizer

checkpoint = "t5-small"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)`,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>checkpoint = <span class="hljs-string">&quot;t5-small&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)`}}),Mt=new X({props:{code:`prefix = "summarize: "


def preprocess_function(examples):
    inputs = [prefix + doc for doc in examples["text"]]
    model_inputs = tokenizer(inputs, max_length=1024, truncation=True)

    labels = tokenizer(text_target=examples["summary"], max_length=128, truncation=True)

    model_inputs["labels"] = labels["input_ids"]
    return model_inputs`,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`}}),Dt=new X({props:{code:"tokenized_billsum = billsum.map(preprocess_function, batched=True)",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>)'}}),bt=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Lr],pytorch:[Fr]},$$scope:{ctx:R}}}),It=new na({}),Ht=new X({props:{code:`import evaluate

rouge = evaluate.load("rouge")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>rouge = evaluate.load(<span class="hljs-string">&quot;rouge&quot;</span>)`}}),Ut=new X({props:{code:`import numpy as np


def compute_metrics(eval_pred):
    predictions, labels = eval_pred
    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    result = rouge.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=True)

    prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) for pred in predictions]
    result["gen_len"] = np.mean(prediction_lens)

    return {k: round(v, 4) for k, v in result.items()}`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    predictions, labels = eval_pred
<span class="hljs-meta">... </span>    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-meta">... </span>    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
<span class="hljs-meta">... </span>    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    result = rouge.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> predictions]
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;gen_len&quot;</span>] = np.mean(prediction_lens)

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> {k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}`}}),Rt=new na({}),jt=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Hr],pytorch:[Or]},$$scope:{ctx:R}}}),Et=new bs({props:{$$slots:{default:[Gr]},$$scope:{ctx:R}}}),Yt=new na({}),Kt=new X({props:{code:`text = "summarize: The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It's the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country. It'll lower the deficit and ask the ultra-wealthy and corporations to pay their fair share. And no one making under $400,000 per year will pay a penny more in taxes."`,highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;summarize: The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It&#x27;s the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country. It&#x27;ll lower the deficit and ask the ultra-wealthy and corporations to pay their fair share. And no one making under $400,000 per year will pay a penny more in taxes.&quot;</span>'}}),Wt=new X({props:{code:`from transformers import pipeline

summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model")
summarizer(text)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>summarizer = pipeline(<span class="hljs-string">&quot;summarization&quot;</span>, model=<span class="hljs-string">&quot;stevhliu/my_awesome_billsum_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>summarizer(text)
[{<span class="hljs-string">&quot;summary_text&quot;</span>: <span class="hljs-string">&quot;The Inflation Reduction Act lowers prescription drug costs, health care costs, and energy costs. It&#x27;s the most aggressive action on tackling the climate crisis in American history, which will lift up American workers and create good-paying, union jobs across the country.&quot;</span>}]`}}),St=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Kr],pytorch:[Rr]},$$scope:{ctx:R}}}),{c(){p=r("meta"),f=d(),l=r("h1"),$=r("a"),y=r("span"),E(j.$$.fragment),P=d(),I=r("span"),k=s("Summarization"),F=d(),E(C.$$.fragment),N=d(),E(B.$$.fragment),O=d(),D=r("p"),pe=s("Summarization creates a shorter version of a document or an article that captures all the important information. Along with translation, it is another example of a task that can be formulated as a sequence-to-sequence task. Summarization can be:"),V=d(),L=r("ul"),Z=r("li"),Y=s("Extractive: extract the most relevant information from a document."),ee=d(),K=r("li"),H=s("Abstractive: generate new text that captures the most relevant information."),G=d(),u=r("p"),v=s("This guide will show you how to:"),te=d(),U=r("ol"),ae=r("li"),W=s("Finetune "),J=r("a"),Ee=s("T5"),ce=s(" on the California state bill subset of the "),qe=r("a"),we=s("BillSum"),ze=s(" dataset for abstractive summarization."),Oe=d(),Pe=r("li"),Q=s("Use your finetuned model for inference."),De=d(),E(oe.$$.fragment),Te=d(),Ce=r("p"),Se=s("Before you begin, make sure you have all the necessary libraries installed:"),me=d(),E(ye.$$.fragment),ue=d(),re=r("p"),Ae=s("We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),_e=d(),E(de.$$.fragment),ke=d(),ne=r("h2"),le=r("a"),b=r("span"),E(M.$$.fragment),ge=d(),xe=r("span"),Fe=s("Load BillSum dataset"),se=d(),$e=r("p"),Be=s("Start by loading the smaller California state bill subset of the BillSum dataset from the \u{1F917} Datasets library:"),fe=d(),E(Me.$$.fragment),he=d(),ie=r("p"),Ne=s("Split the dataset into a train and test set with the "),ve=r("a"),Le=s("train_test_split"),je=s(" method:"),be=d(),E(w.$$.fragment),tt=d(),He=r("p"),c=s("Then take a look at an example:"),z=d(),E(Ie.$$.fragment),Ge=d(),Ve=r("p"),lt=s("There are two fields that you\u2019ll want to use:"),Je=d(),Ue=r("ul"),Qe=r("li"),Ye=r("code"),it=s("text"),Ke=s(": the text of the bill which\u2019ll be the input to the model."),pt=d(),Re=r("li"),We=r("code"),ct=s("summary"),mt=s(": a condensed version of "),Xe=r("code"),ft=s("text"),ht=s(" which\u2019ll be the model target."),at=d(),ut=r("h2"),$t=r("a"),ia=r("span"),E(zt.$$.fragment),ys=d(),pa=r("span"),ks=s("Preprocess"),Pa=d(),st=r("p"),vs=s("The next step is to load a T5 tokenizer to process "),ca=r("code"),js=s("text"),Es=s(" and "),ma=r("code"),qs=s("summary"),Ts=s(":"),Ca=d(),E(Pt.$$.fragment),Fa=d(),Vt=r("p"),Ss=s("The preprocessing function you want to create needs to:"),Ma=d(),ot=r("ol"),fa=r("li"),As=s("Prefix the input with a prompt so T5 knows this is a summarization task. Some models capable of multiple NLP tasks require prompting for specific tasks."),xs=d(),Ct=r("li"),zs=s("Use the keyword "),ha=r("code"),Ps=s("text_target"),Cs=s(" argument when tokenizing labels."),Fs=d(),Ft=r("li"),Ms=s("Truncate sequences to be no longer than the maximum length set by the "),ua=r("code"),Ls=s("max_length"),Ds=s(" parameter."),La=d(),E(Mt.$$.fragment),Da=d(),Ze=r("p"),Is=s("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),Lt=r("a"),Os=s("map"),Bs=s(" method. You can speed up the "),da=r("code"),Ns=s("map"),Hs=s(" function by setting "),_a=r("code"),Gs=s("batched=True"),Us=s(" to process multiple elements of the dataset at once:"),Ia=d(),E(Dt.$$.fragment),Oa=d(),rt=r("p"),Rs=s("Now create a batch of examples using "),Jt=r("a"),Ys=s("DataCollatorForSeq2Seq"),Ks=s(". It\u2019s more efficient to "),ga=r("em"),Ws=s("dynamically pad"),Xs=s(" the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length."),Ba=d(),E(bt.$$.fragment),Na=d(),dt=r("h2"),wt=r("a"),$a=r("span"),E(It.$$.fragment),Vs=d(),ba=r("span"),Js=s("Evaluate"),Ha=d(),et=r("p"),Qs=s("Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ot=r("a"),Zs=s("Evaluate"),eo=s(" library. For this task, load the "),Bt=r("a"),to=s("ROUGE"),ao=s(" metric (see the \u{1F917} Evaluate "),Nt=r("a"),so=s("quick tour"),oo=s(" to learn more about how to load and compute a metric):"),Ga=d(),E(Ht.$$.fragment),Ua=d(),yt=r("p"),ro=s("Then create a function that passes your predictions and labels to "),Gt=r("a"),no=s("compute"),lo=s(" to calculate the ROUGE metric:"),Ra=d(),E(Ut.$$.fragment),Ya=d(),kt=r("p"),io=s("Your "),wa=r("code"),po=s("compute_metrics"),co=s(" function is ready to go now, and you\u2019ll return to it when you setup your training."),Ka=d(),_t=r("h2"),vt=r("a"),ya=r("span"),E(Rt.$$.fragment),mo=d(),ka=r("span"),fo=s("Train"),Wa=d(),E(jt.$$.fragment),Xa=d(),E(Et.$$.fragment),Va=d(),gt=r("h2"),qt=r("a"),va=r("span"),E(Yt.$$.fragment),ho=d(),ja=r("span"),uo=s("Inference"),Ja=d(),Qt=r("p"),_o=s("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Qa=d(),Zt=r("p"),go=s("Come up with some text you\u2019d like to summarize. For T5, you need to prefix your input depending on the task you\u2019re working on. For summarization you should prefix your input as shown below:"),Za=d(),E(Kt.$$.fragment),es=d(),nt=r("p"),$o=s("The simplest way to try out your finetuned model for inference is to use it in a "),ea=r("a"),bo=s("pipeline()"),wo=s(". Instantiate a "),Ea=r("code"),yo=s("pipeline"),ko=s(" for summarization with your model, and pass your text to it:"),ts=d(),E(Wt.$$.fragment),as=d(),Tt=r("p"),vo=s("You can also manually replicate the results of the "),qa=r("code"),jo=s("pipeline"),Eo=s(" if you\u2019d like:"),ss=d(),E(St.$$.fragment),this.h()},l(e){const h=Sr('[data-svelte="svelte-1phssyn"]',document.head);p=n(h,"META",{name:!0,content:!0}),h.forEach(a),f=_(e),l=n(e,"H1",{class:!0});var Xt=i(l);$=n(Xt,"A",{id:!0,class:!0,href:!0});var Ta=i($);y=n(Ta,"SPAN",{});var Sa=i(y);q(j.$$.fragment,Sa),Sa.forEach(a),Ta.forEach(a),P=_(Xt),I=n(Xt,"SPAN",{});var Aa=i(I);k=o(Aa,"Summarization"),Aa.forEach(a),Xt.forEach(a),F=_(e),q(C.$$.fragment,e),N=_(e),q(B.$$.fragment,e),O=_(e),D=n(e,"P",{});var xa=i(D);pe=o(xa,"Summarization creates a shorter version of a document or an article that captures all the important information. Along with translation, it is another example of a task that can be formulated as a sequence-to-sequence task. Summarization can be:"),xa.forEach(a),V=_(e),L=n(e,"UL",{});var rs=i(L);Z=n(rs,"LI",{});var So=i(Z);Y=o(So,"Extractive: extract the most relevant information from a document."),So.forEach(a),ee=_(rs),K=n(rs,"LI",{});var Ao=i(K);H=o(Ao,"Abstractive: generate new text that captures the most relevant information."),Ao.forEach(a),rs.forEach(a),G=_(e),u=n(e,"P",{});var xo=i(u);v=o(xo,"This guide will show you how to:"),xo.forEach(a),te=_(e),U=n(e,"OL",{});var ns=i(U);ae=n(ns,"LI",{});var ta=i(ae);W=o(ta,"Finetune "),J=n(ta,"A",{href:!0,rel:!0});var zo=i(J);Ee=o(zo,"T5"),zo.forEach(a),ce=o(ta," on the California state bill subset of the "),qe=n(ta,"A",{href:!0,rel:!0});var Po=i(qe);we=o(Po,"BillSum"),Po.forEach(a),ze=o(ta," dataset for abstractive summarization."),ta.forEach(a),Oe=_(ns),Pe=n(ns,"LI",{});var Co=i(Pe);Q=o(Co,"Use your finetuned model for inference."),Co.forEach(a),ns.forEach(a),De=_(e),q(oe.$$.fragment,e),Te=_(e),Ce=n(e,"P",{});var Fo=i(Ce);Se=o(Fo,"Before you begin, make sure you have all the necessary libraries installed:"),Fo.forEach(a),me=_(e),q(ye.$$.fragment,e),ue=_(e),re=n(e,"P",{});var Mo=i(re);Ae=o(Mo,"We encourage you to login to your Hugging Face account so you can upload and share your model with the community. When prompted, enter your token to login:"),Mo.forEach(a),_e=_(e),q(de.$$.fragment,e),ke=_(e),ne=n(e,"H2",{class:!0});var ls=i(ne);le=n(ls,"A",{id:!0,class:!0,href:!0});var Lo=i(le);b=n(Lo,"SPAN",{});var Do=i(b);q(M.$$.fragment,Do),Do.forEach(a),Lo.forEach(a),ge=_(ls),xe=n(ls,"SPAN",{});var Io=i(xe);Fe=o(Io,"Load BillSum dataset"),Io.forEach(a),ls.forEach(a),se=_(e),$e=n(e,"P",{});var Oo=i($e);Be=o(Oo,"Start by loading the smaller California state bill subset of the BillSum dataset from the \u{1F917} Datasets library:"),Oo.forEach(a),fe=_(e),q(Me.$$.fragment,e),he=_(e),ie=n(e,"P",{});var is=i(ie);Ne=o(is,"Split the dataset into a train and test set with the "),ve=n(is,"A",{href:!0,rel:!0});var Bo=i(ve);Le=o(Bo,"train_test_split"),Bo.forEach(a),je=o(is," method:"),is.forEach(a),be=_(e),q(w.$$.fragment,e),tt=_(e),He=n(e,"P",{});var No=i(He);c=o(No,"Then take a look at an example:"),No.forEach(a),z=_(e),q(Ie.$$.fragment,e),Ge=_(e),Ve=n(e,"P",{});var Ho=i(Ve);lt=o(Ho,"There are two fields that you\u2019ll want to use:"),Ho.forEach(a),Je=_(e),Ue=n(e,"UL",{});var ps=i(Ue);Qe=n(ps,"LI",{});var qo=i(Qe);Ye=n(qo,"CODE",{});var Go=i(Ye);it=o(Go,"text"),Go.forEach(a),Ke=o(qo,": the text of the bill which\u2019ll be the input to the model."),qo.forEach(a),pt=_(ps),Re=n(ps,"LI",{});var za=i(Re);We=n(za,"CODE",{});var Uo=i(We);ct=o(Uo,"summary"),Uo.forEach(a),mt=o(za,": a condensed version of "),Xe=n(za,"CODE",{});var Ro=i(Xe);ft=o(Ro,"text"),Ro.forEach(a),ht=o(za," which\u2019ll be the model target."),za.forEach(a),ps.forEach(a),at=_(e),ut=n(e,"H2",{class:!0});var cs=i(ut);$t=n(cs,"A",{id:!0,class:!0,href:!0});var Yo=i($t);ia=n(Yo,"SPAN",{});var Ko=i(ia);q(zt.$$.fragment,Ko),Ko.forEach(a),Yo.forEach(a),ys=_(cs),pa=n(cs,"SPAN",{});var Wo=i(pa);ks=o(Wo,"Preprocess"),Wo.forEach(a),cs.forEach(a),Pa=_(e),st=n(e,"P",{});var aa=i(st);vs=o(aa,"The next step is to load a T5 tokenizer to process "),ca=n(aa,"CODE",{});var Xo=i(ca);js=o(Xo,"text"),Xo.forEach(a),Es=o(aa," and "),ma=n(aa,"CODE",{});var Vo=i(ma);qs=o(Vo,"summary"),Vo.forEach(a),Ts=o(aa,":"),aa.forEach(a),Ca=_(e),q(Pt.$$.fragment,e),Fa=_(e),Vt=n(e,"P",{});var Jo=i(Vt);Ss=o(Jo,"The preprocessing function you want to create needs to:"),Jo.forEach(a),Ma=_(e),ot=n(e,"OL",{});var sa=i(ot);fa=n(sa,"LI",{});var Qo=i(fa);As=o(Qo,"Prefix the input with a prompt so T5 knows this is a summarization task. Some models capable of multiple NLP tasks require prompting for specific tasks."),Qo.forEach(a),xs=_(sa),Ct=n(sa,"LI",{});var ms=i(Ct);zs=o(ms,"Use the keyword "),ha=n(ms,"CODE",{});var Zo=i(ha);Ps=o(Zo,"text_target"),Zo.forEach(a),Cs=o(ms," argument when tokenizing labels."),ms.forEach(a),Fs=_(sa),Ft=n(sa,"LI",{});var fs=i(Ft);Ms=o(fs,"Truncate sequences to be no longer than the maximum length set by the "),ua=n(fs,"CODE",{});var er=i(ua);Ls=o(er,"max_length"),er.forEach(a),Ds=o(fs," parameter."),fs.forEach(a),sa.forEach(a),La=_(e),q(Mt.$$.fragment,e),Da=_(e),Ze=n(e,"P",{});var At=i(Ze);Is=o(At,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),Lt=n(At,"A",{href:!0,rel:!0});var tr=i(Lt);Os=o(tr,"map"),tr.forEach(a),Bs=o(At," method. You can speed up the "),da=n(At,"CODE",{});var ar=i(da);Ns=o(ar,"map"),ar.forEach(a),Hs=o(At," function by setting "),_a=n(At,"CODE",{});var sr=i(_a);Gs=o(sr,"batched=True"),sr.forEach(a),Us=o(At," to process multiple elements of the dataset at once:"),At.forEach(a),Ia=_(e),q(Dt.$$.fragment,e),Oa=_(e),rt=n(e,"P",{});var oa=i(rt);Rs=o(oa,"Now create a batch of examples using "),Jt=n(oa,"A",{href:!0});var or=i(Jt);Ys=o(or,"DataCollatorForSeq2Seq"),or.forEach(a),Ks=o(oa,". It\u2019s more efficient to "),ga=n(oa,"EM",{});var rr=i(ga);Ws=o(rr,"dynamically pad"),rr.forEach(a),Xs=o(oa," the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length."),oa.forEach(a),Ba=_(e),q(bt.$$.fragment,e),Na=_(e),dt=n(e,"H2",{class:!0});var hs=i(dt);wt=n(hs,"A",{id:!0,class:!0,href:!0});var nr=i(wt);$a=n(nr,"SPAN",{});var lr=i($a);q(It.$$.fragment,lr),lr.forEach(a),nr.forEach(a),Vs=_(hs),ba=n(hs,"SPAN",{});var ir=i(ba);Js=o(ir,"Evaluate"),ir.forEach(a),hs.forEach(a),Ha=_(e),et=n(e,"P",{});var xt=i(et);Qs=o(xt,"Including a metric during training is often helpful for evaluating your model\u2019s performance. You can quickly load a evaluation method with the \u{1F917} "),Ot=n(xt,"A",{href:!0,rel:!0});var pr=i(Ot);Zs=o(pr,"Evaluate"),pr.forEach(a),eo=o(xt," library. For this task, load the "),Bt=n(xt,"A",{href:!0,rel:!0});var cr=i(Bt);to=o(cr,"ROUGE"),cr.forEach(a),ao=o(xt," metric (see the \u{1F917} Evaluate "),Nt=n(xt,"A",{href:!0,rel:!0});var mr=i(Nt);so=o(mr,"quick tour"),mr.forEach(a),oo=o(xt," to learn more about how to load and compute a metric):"),xt.forEach(a),Ga=_(e),q(Ht.$$.fragment,e),Ua=_(e),yt=n(e,"P",{});var us=i(yt);ro=o(us,"Then create a function that passes your predictions and labels to "),Gt=n(us,"A",{href:!0,rel:!0});var fr=i(Gt);no=o(fr,"compute"),fr.forEach(a),lo=o(us," to calculate the ROUGE metric:"),us.forEach(a),Ra=_(e),q(Ut.$$.fragment,e),Ya=_(e),kt=n(e,"P",{});var ds=i(kt);io=o(ds,"Your "),wa=n(ds,"CODE",{});var hr=i(wa);po=o(hr,"compute_metrics"),hr.forEach(a),co=o(ds," function is ready to go now, and you\u2019ll return to it when you setup your training."),ds.forEach(a),Ka=_(e),_t=n(e,"H2",{class:!0});var _s=i(_t);vt=n(_s,"A",{id:!0,class:!0,href:!0});var ur=i(vt);ya=n(ur,"SPAN",{});var dr=i(ya);q(Rt.$$.fragment,dr),dr.forEach(a),ur.forEach(a),mo=_(_s),ka=n(_s,"SPAN",{});var _r=i(ka);fo=o(_r,"Train"),_r.forEach(a),_s.forEach(a),Wa=_(e),q(jt.$$.fragment,e),Xa=_(e),q(Et.$$.fragment,e),Va=_(e),gt=n(e,"H2",{class:!0});var gs=i(gt);qt=n(gs,"A",{id:!0,class:!0,href:!0});var gr=i(qt);va=n(gr,"SPAN",{});var $r=i(va);q(Yt.$$.fragment,$r),$r.forEach(a),gr.forEach(a),ho=_(gs),ja=n(gs,"SPAN",{});var br=i(ja);uo=o(br,"Inference"),br.forEach(a),gs.forEach(a),Ja=_(e),Qt=n(e,"P",{});var wr=i(Qt);_o=o(wr,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),wr.forEach(a),Qa=_(e),Zt=n(e,"P",{});var yr=i(Zt);go=o(yr,"Come up with some text you\u2019d like to summarize. For T5, you need to prefix your input depending on the task you\u2019re working on. For summarization you should prefix your input as shown below:"),yr.forEach(a),Za=_(e),q(Kt.$$.fragment,e),es=_(e),nt=n(e,"P",{});var ra=i(nt);$o=o(ra,"The simplest way to try out your finetuned model for inference is to use it in a "),ea=n(ra,"A",{href:!0});var kr=i(ea);bo=o(kr,"pipeline()"),kr.forEach(a),wo=o(ra,". Instantiate a "),Ea=n(ra,"CODE",{});var vr=i(Ea);yo=o(vr,"pipeline"),vr.forEach(a),ko=o(ra," for summarization with your model, and pass your text to it:"),ra.forEach(a),ts=_(e),q(Wt.$$.fragment,e),as=_(e),Tt=n(e,"P",{});var $s=i(Tt);vo=o($s,"You can also manually replicate the results of the "),qa=n($s,"CODE",{});var jr=i(qa);jo=o(jr,"pipeline"),jr.forEach(a),Eo=o($s," if you\u2019d like:"),$s.forEach(a),ss=_(e),q(St.$$.fragment,e),this.h()},h(){g(p,"name","hf:doc:metadata"),g(p,"content",JSON.stringify(Xr)),g($,"id","summarization"),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"),g($,"href","#summarization"),g(l,"class","relative group"),g(J,"href","https://huggingface.co/t5-small"),g(J,"rel","nofollow"),g(qe,"href","https://huggingface.co/datasets/billsum"),g(qe,"rel","nofollow"),g(le,"id","load-billsum-dataset"),g(le,"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"),g(le,"href","#load-billsum-dataset"),g(ne,"class","relative group"),g(ve,"href","https://huggingface.co/docs/datasets/v2.12.0/en/package_reference/main_classes#datasets.Dataset.train_test_split"),g(ve,"rel","nofollow"),g($t,"id","preprocess"),g($t,"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"),g($t,"href","#preprocess"),g(ut,"class","relative group"),g(Lt,"href","https://huggingface.co/docs/datasets/v2.12.0/en/package_reference/main_classes#datasets.Dataset.map"),g(Lt,"rel","nofollow"),g(Jt,"href","/docs/transformers/v4.29.0/en/main_classes/data_collator#transformers.DataCollatorForSeq2Seq"),g(wt,"id","evaluate"),g(wt,"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"),g(wt,"href","#evaluate"),g(dt,"class","relative group"),g(Ot,"href","https://huggingface.co/docs/evaluate/index"),g(Ot,"rel","nofollow"),g(Bt,"href","https://huggingface.co/spaces/evaluate-metric/rouge"),g(Bt,"rel","nofollow"),g(Nt,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),g(Nt,"rel","nofollow"),g(Gt,"href","https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),g(Gt,"rel","nofollow"),g(vt,"id","train"),g(vt,"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"),g(vt,"href","#train"),g(_t,"class","relative group"),g(qt,"id","inference"),g(qt,"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"),g(qt,"href","#inference"),g(gt,"class","relative group"),g(ea,"href","/docs/transformers/v4.29.0/en/main_classes/pipelines#transformers.pipeline")},m(e,h){t(document.head,p),m(e,f,h),m(e,l,h),t(l,$),t($,y),T(j,y,null),t(l,P),t(l,I),t(I,k),m(e,F,h),T(C,e,h),m(e,N,h),T(B,e,h),m(e,O,h),m(e,D,h),t(D,pe),m(e,V,h),m(e,L,h),t(L,Z),t(Z,Y),t(L,ee),t(L,K),t(K,H),m(e,G,h),m(e,u,h),t(u,v),m(e,te,h),m(e,U,h),t(U,ae),t(ae,W),t(ae,J),t(J,Ee),t(ae,ce),t(ae,qe),t(qe,we),t(ae,ze),t(U,Oe),t(U,Pe),t(Pe,Q),m(e,De,h),T(oe,e,h),m(e,Te,h),m(e,Ce,h),t(Ce,Se),m(e,me,h),T(ye,e,h),m(e,ue,h),m(e,re,h),t(re,Ae),m(e,_e,h),T(de,e,h),m(e,ke,h),m(e,ne,h),t(ne,le),t(le,b),T(M,b,null),t(ne,ge),t(ne,xe),t(xe,Fe),m(e,se,h),m(e,$e,h),t($e,Be),m(e,fe,h),T(Me,e,h),m(e,he,h),m(e,ie,h),t(ie,Ne),t(ie,ve),t(ve,Le),t(ie,je),m(e,be,h),T(w,e,h),m(e,tt,h),m(e,He,h),t(He,c),m(e,z,h),T(Ie,e,h),m(e,Ge,h),m(e,Ve,h),t(Ve,lt),m(e,Je,h),m(e,Ue,h),t(Ue,Qe),t(Qe,Ye),t(Ye,it),t(Qe,Ke),t(Ue,pt),t(Ue,Re),t(Re,We),t(We,ct),t(Re,mt),t(Re,Xe),t(Xe,ft),t(Re,ht),m(e,at,h),m(e,ut,h),t(ut,$t),t($t,ia),T(zt,ia,null),t(ut,ys),t(ut,pa),t(pa,ks),m(e,Pa,h),m(e,st,h),t(st,vs),t(st,ca),t(ca,js),t(st,Es),t(st,ma),t(ma,qs),t(st,Ts),m(e,Ca,h),T(Pt,e,h),m(e,Fa,h),m(e,Vt,h),t(Vt,Ss),m(e,Ma,h),m(e,ot,h),t(ot,fa),t(fa,As),t(ot,xs),t(ot,Ct),t(Ct,zs),t(Ct,ha),t(ha,Ps),t(Ct,Cs),t(ot,Fs),t(ot,Ft),t(Ft,Ms),t(Ft,ua),t(ua,Ls),t(Ft,Ds),m(e,La,h),T(Mt,e,h),m(e,Da,h),m(e,Ze,h),t(Ze,Is),t(Ze,Lt),t(Lt,Os),t(Ze,Bs),t(Ze,da),t(da,Ns),t(Ze,Hs),t(Ze,_a),t(_a,Gs),t(Ze,Us),m(e,Ia,h),T(Dt,e,h),m(e,Oa,h),m(e,rt,h),t(rt,Rs),t(rt,Jt),t(Jt,Ys),t(rt,Ks),t(rt,ga),t(ga,Ws),t(rt,Xs),m(e,Ba,h),T(bt,e,h),m(e,Na,h),m(e,dt,h),t(dt,wt),t(wt,$a),T(It,$a,null),t(dt,Vs),t(dt,ba),t(ba,Js),m(e,Ha,h),m(e,et,h),t(et,Qs),t(et,Ot),t(Ot,Zs),t(et,eo),t(et,Bt),t(Bt,to),t(et,ao),t(et,Nt),t(Nt,so),t(et,oo),m(e,Ga,h),T(Ht,e,h),m(e,Ua,h),m(e,yt,h),t(yt,ro),t(yt,Gt),t(Gt,no),t(yt,lo),m(e,Ra,h),T(Ut,e,h),m(e,Ya,h),m(e,kt,h),t(kt,io),t(kt,wa),t(wa,po),t(kt,co),m(e,Ka,h),m(e,_t,h),t(_t,vt),t(vt,ya),T(Rt,ya,null),t(_t,mo),t(_t,ka),t(ka,fo),m(e,Wa,h),T(jt,e,h),m(e,Xa,h),T(Et,e,h),m(e,Va,h),m(e,gt,h),t(gt,qt),t(qt,va),T(Yt,va,null),t(gt,ho),t(gt,ja),t(ja,uo),m(e,Ja,h),m(e,Qt,h),t(Qt,_o),m(e,Qa,h),m(e,Zt,h),t(Zt,go),m(e,Za,h),T(Kt,e,h),m(e,es,h),m(e,nt,h),t(nt,$o),t(nt,ea),t(ea,bo),t(nt,wo),t(nt,Ea),t(Ea,yo),t(nt,ko),m(e,ts,h),T(Wt,e,h),m(e,as,h),m(e,Tt,h),t(Tt,vo),t(Tt,qa),t(qa,jo),t(Tt,Eo),m(e,ss,h),T(St,e,h),os=!0},p(e,[h]){const Xt={};h&2&&(Xt.$$scope={dirty:h,ctx:e}),oe.$set(Xt);const Ta={};h&2&&(Ta.$$scope={dirty:h,ctx:e}),bt.$set(Ta);const Sa={};h&2&&(Sa.$$scope={dirty:h,ctx:e}),jt.$set(Sa);const Aa={};h&2&&(Aa.$$scope={dirty:h,ctx:e}),Et.$set(Aa);const xa={};h&2&&(xa.$$scope={dirty:h,ctx:e}),St.$set(xa)},i(e){os||(S(j.$$.fragment,e),S(C.$$.fragment,e),S(B.$$.fragment,e),S(oe.$$.fragment,e),S(ye.$$.fragment,e),S(de.$$.fragment,e),S(M.$$.fragment,e),S(Me.$$.fragment,e),S(w.$$.fragment,e),S(Ie.$$.fragment,e),S(zt.$$.fragment,e),S(Pt.$$.fragment,e),S(Mt.$$.fragment,e),S(Dt.$$.fragment,e),S(bt.$$.fragment,e),S(It.$$.fragment,e),S(Ht.$$.fragment,e),S(Ut.$$.fragment,e),S(Rt.$$.fragment,e),S(jt.$$.fragment,e),S(Et.$$.fragment,e),S(Yt.$$.fragment,e),S(Kt.$$.fragment,e),S(Wt.$$.fragment,e),S(St.$$.fragment,e),os=!0)},o(e){A(j.$$.fragment,e),A(C.$$.fragment,e),A(B.$$.fragment,e),A(oe.$$.fragment,e),A(ye.$$.fragment,e),A(de.$$.fragment,e),A(M.$$.fragment,e),A(Me.$$.fragment,e),A(w.$$.fragment,e),A(Ie.$$.fragment,e),A(zt.$$.fragment,e),A(Pt.$$.fragment,e),A(Mt.$$.fragment,e),A(Dt.$$.fragment,e),A(bt.$$.fragment,e),A(It.$$.fragment,e),A(Ht.$$.fragment,e),A(Ut.$$.fragment,e),A(Rt.$$.fragment,e),A(jt.$$.fragment,e),A(Et.$$.fragment,e),A(Yt.$$.fragment,e),A(Kt.$$.fragment,e),A(Wt.$$.fragment,e),A(St.$$.fragment,e),os=!1},d(e){a(p),e&&a(f),e&&a(l),x(j),e&&a(F),x(C,e),e&&a(N),x(B,e),e&&a(O),e&&a(D),e&&a(V),e&&a(L),e&&a(G),e&&a(u),e&&a(te),e&&a(U),e&&a(De),x(oe,e),e&&a(Te),e&&a(Ce),e&&a(me),x(ye,e),e&&a(ue),e&&a(re),e&&a(_e),x(de,e),e&&a(ke),e&&a(ne),x(M),e&&a(se),e&&a($e),e&&a(fe),x(Me,e),e&&a(he),e&&a(ie),e&&a(be),x(w,e),e&&a(tt),e&&a(He),e&&a(z),x(Ie,e),e&&a(Ge),e&&a(Ve),e&&a(Je),e&&a(Ue),e&&a(at),e&&a(ut),x(zt),e&&a(Pa),e&&a(st),e&&a(Ca),x(Pt,e),e&&a(Fa),e&&a(Vt),e&&a(Ma),e&&a(ot),e&&a(La),x(Mt,e),e&&a(Da),e&&a(Ze),e&&a(Ia),x(Dt,e),e&&a(Oa),e&&a(rt),e&&a(Ba),x(bt,e),e&&a(Na),e&&a(dt),x(It),e&&a(Ha),e&&a(et),e&&a(Ga),x(Ht,e),e&&a(Ua),e&&a(yt),e&&a(Ra),x(Ut,e),e&&a(Ya),e&&a(kt),e&&a(Ka),e&&a(_t),x(Rt),e&&a(Wa),x(jt,e),e&&a(Xa),x(Et,e),e&&a(Va),e&&a(gt),x(Yt),e&&a(Ja),e&&a(Qt),e&&a(Qa),e&&a(Zt),e&&a(Za),x(Kt,e),e&&a(es),e&&a(nt),e&&a(ts),x(Wt,e),e&&a(as),e&&a(Tt),e&&a(ss),x(St,e)}}}const Xr={local:"summarization",sections:[{local:"load-billsum-dataset",title:"Load BillSum dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Summarization"};function Vr(R){return Ar(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class on extends Er{constructor(p){super();qr(this,p,Vr,Wr,Tr,{})}}export{on as default,Xr as metadata};
