import{S as Er,i as qr,s as Tr,e as n,k as d,w as E,t as s,M as Sr,c as l,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 ra}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 na}from"../../chunks/Markdown-hf-doc-builder.js";function Pr(R){let p,h,r,$,w,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,ve,ce,je,we,xe,Ie,ze,Q,Le,oe,Ee,Pe,qe,me,ye,de,re,Te,ge,_e,ke,ne,le,b,M,$e,Se,Ce,se,be,Oe,he,Fe,fe,ie,Ne;return{c(){p=s(`The task illustrated in this tutorial is supported by the following model architectures:

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

`),h=l(ue,"P",{});var y=i(h);r=l(y,"A",{href:!0});var Ae=i(r);$=o(Ae,"BART"),Ae.forEach(a),w=o(y,", "),j=l(y,"A",{href:!0});var Be=i(j);P=o(Be,"BigBird-Pegasus"),Be.forEach(a),I=o(y,", "),k=l(y,"A",{href:!0});var Me=i(k);F=o(Me,"Blenderbot"),Me.forEach(a),C=o(y,", "),N=l(y,"A",{href:!0});var et=i(N);B=o(et,"BlenderbotSmall"),et.forEach(a),O=o(y,", "),D=l(y,"A",{href:!0});var He=i(D);pe=o(He,"Encoder decoder"),He.forEach(a),V=o(y,", "),L=l(y,"A",{href:!0});var c=i(L);Z=o(c,"FairSeq Machine-Translation"),c.forEach(a),Y=o(y,", "),ee=l(y,"A",{href:!0});var z=i(ee);K=o(z,"GPTSAN-japanese"),z.forEach(a),H=o(y,", "),G=l(y,"A",{href:!0});var De=i(G);u=o(De,"LED"),De.forEach(a),v=o(y,", "),te=l(y,"A",{href:!0});var Ge=i(te);U=o(Ge,"LongT5"),Ge.forEach(a),ae=o(y,", "),W=l(y,"A",{href:!0});var Xe=i(W);J=o(Xe,"M2M100"),Xe.forEach(a),ve=o(y,", "),ce=l(y,"A",{href:!0});var nt=i(ce);je=o(nt,"Marian"),nt.forEach(a),we=o(y,", "),xe=l(y,"A",{href:!0});var Ve=i(xe);Ie=o(Ve,"mBART"),Ve.forEach(a),ze=o(y,", "),Q=l(y,"A",{href:!0});var Ue=i(Q);Le=o(Ue,"MT5"),Ue.forEach(a),oe=o(y,", "),Ee=l(y,"A",{href:!0});var Je=i(Ee);Pe=o(Je,"MVP"),Je.forEach(a),qe=o(y,", "),me=l(y,"A",{href:!0});var Ye=i(me);ye=o(Ye,"NLLB"),Ye.forEach(a),de=o(y,", "),re=l(y,"A",{href:!0});var lt=i(re);Te=o(lt,"Pegasus"),lt.forEach(a),ge=o(y,", "),_e=l(y,"A",{href:!0});var Ke=i(_e);ke=o(Ke,"PEGASUS-X"),Ke.forEach(a),ne=o(y,", "),le=l(y,"A",{href:!0});var it=i(le);b=o(it,"PLBart"),it.forEach(a),M=o(y,", "),$e=l(y,"A",{href:!0});var Re=i($e);Se=o(Re,"ProphetNet"),Re.forEach(a),Ce=o(y,", "),se=l(y,"A",{href:!0});var We=i(se);be=o(We,"SwitchTransformers"),We.forEach(a),Oe=o(y,", "),he=l(y,"A",{href:!0});var pt=i(he);Fe=o(pt,"T5"),pt.forEach(a),fe=o(y,", "),ie=l(y,"A",{href:!0});var ct=i(ie);Ne=o(ct,"XLM-ProphetNet"),ct.forEach(a),y.forEach(a),this.h()},h(){g(r,"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(xe,"href","../model_doc/mbart"),g(Q,"href","../model_doc/mt5"),g(Ee,"href","../model_doc/mvp"),g(me,"href","../model_doc/nllb"),g(re,"href","../model_doc/pegasus"),g(_e,"href","../model_doc/pegasus_x"),g(le,"href","../model_doc/plbart"),g($e,"href","../model_doc/prophetnet"),g(se,"href","../model_doc/switch_transformers"),g(he,"href","../model_doc/t5"),g(ie,"href","../model_doc/xlm-prophetnet")},m(ue,y){m(ue,p,y),m(ue,h,y),t(h,r),t(r,$),t(h,w),t(h,j),t(j,P),t(h,I),t(h,k),t(k,F),t(h,C),t(h,N),t(N,B),t(h,O),t(h,D),t(D,pe),t(h,V),t(h,L),t(L,Z),t(h,Y),t(h,ee),t(ee,K),t(h,H),t(h,G),t(G,u),t(h,v),t(h,te),t(te,U),t(h,ae),t(h,W),t(W,J),t(h,ve),t(h,ce),t(ce,je),t(h,we),t(h,xe),t(xe,Ie),t(h,ze),t(h,Q),t(Q,Le),t(h,oe),t(h,Ee),t(Ee,Pe),t(h,qe),t(h,me),t(me,ye),t(h,de),t(h,re),t(re,Te),t(h,ge),t(h,_e),t(_e,ke),t(h,ne),t(h,le),t(le,b),t(h,M),t(h,$e),t($e,Se),t(h,Ce),t(h,se),t(se,be),t(h,Oe),t(h,he),t(he,Fe),t(h,fe),t(h,ie),t(ie,Ne)},d(ue){ue&&a(p),ue&&a(h)}}}function Cr(R){let p,h;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(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p:ws,i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Fr(R){let p,h;return p=new na({props:{$$slots:{default:[Cr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Mr(R){let p,h;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(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p:ws,i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Lr(R){let p,h;return p=new na({props:{$$slots:{default:[Mr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Dr(R){let p,h,r,$,w,j,P,I;return{c(){p=n("p"),h=s("If you aren\u2019t familiar with finetuning a model with the "),r=n("a"),$=s("Trainer"),w=s(", take a look at the basic tutorial "),j=n("a"),P=s("here"),I=s("!"),this.h()},l(k){p=l(k,"P",{});var F=i(p);h=o(F,"If you aren\u2019t familiar with finetuning a model with the "),r=l(F,"A",{href:!0});var C=i(r);$=o(C,"Trainer"),C.forEach(a),w=o(F,", take a look at the basic tutorial "),j=l(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(r,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer"),g(j,"href","../training#train-with-pytorch-trainer")},m(k,F){m(k,p,F),t(p,h),t(p,r),t(r,$),t(p,w),t(p,j),t(j,P),t(p,I)},d(k){k&&a(p)}}}function Ir(R){let p,h,r,$,w,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,ve,ce,je,we,xe,Ie,ze,Q,Le,oe,Ee,Pe,qe,me,ye,de,re,Te,ge,_e,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),h=d(),r=n("p"),$=s("You\u2019re ready to start training your model now! Load T5 with "),w=n("a"),j=s("AutoModelForSeq2SeqLM"),P=s(":"),I=d(),E(k.$$.fragment),F=d(),C=n("p"),N=s("At this point, only three steps remain:"),B=d(),O=n("ol"),D=n("li"),pe=s("Define your training hyperparameters in "),V=n("a"),L=s("Seq2SeqTrainingArguments"),Z=s(". The only required parameter is "),Y=n("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=n("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=n("a"),te=s("Trainer"),U=s(" will evaluate the ROUGE metric and save the training checkpoint."),ae=d(),W=n("li"),J=s("Pass the training arguments to "),ve=n("a"),ce=s("Seq2SeqTrainer"),je=s(" along with the model, dataset, tokenizer, data collator, and "),we=n("code"),xe=s("compute_metrics"),Ie=s(" function."),ze=d(),Q=n("li"),Le=s("Call "),oe=n("a"),Ee=s("train()"),Pe=s(" to finetune your model."),qe=d(),E(me.$$.fragment),ye=d(),de=n("p"),re=s("Once training is completed, share your model to the Hub with the "),Te=n("a"),ge=s("push_to_hub()"),_e=s(" method so everyone can use your model:"),ke=d(),E(ne.$$.fragment),this.h()},l(b){q(p.$$.fragment,b),h=_(b),r=l(b,"P",{});var M=i(r);$=o(M,"You\u2019re ready to start training your model now! Load T5 with "),w=l(M,"A",{href:!0});var $e=i(w);j=o($e,"AutoModelForSeq2SeqLM"),$e.forEach(a),P=o(M,":"),M.forEach(a),I=_(b),q(k.$$.fragment,b),F=_(b),C=l(b,"P",{});var Se=i(C);N=o(Se,"At this point, only three steps remain:"),Se.forEach(a),B=_(b),O=l(b,"OL",{});var Ce=i(O);D=l(Ce,"LI",{});var se=i(D);pe=o(se,"Define your training hyperparameters in "),V=l(se,"A",{href:!0});var be=i(V);L=o(be,"Seq2SeqTrainingArguments"),be.forEach(a),Z=o(se,". The only required parameter is "),Y=l(se,"CODE",{});var Oe=i(Y);ee=o(Oe,"output_dir"),Oe.forEach(a),K=o(se," which specifies where to save your model. You\u2019ll push this model to the Hub by setting "),H=l(se,"CODE",{});var he=i(H);G=o(he,"push_to_hub=True"),he.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=l(se,"A",{href:!0});var Fe=i(v);te=o(Fe,"Trainer"),Fe.forEach(a),U=o(se," will evaluate the ROUGE metric and save the training checkpoint."),se.forEach(a),ae=_(Ce),W=l(Ce,"LI",{});var fe=i(W);J=o(fe,"Pass the training arguments to "),ve=l(fe,"A",{href:!0});var ie=i(ve);ce=o(ie,"Seq2SeqTrainer"),ie.forEach(a),je=o(fe," along with the model, dataset, tokenizer, data collator, and "),we=l(fe,"CODE",{});var Ne=i(we);xe=o(Ne,"compute_metrics"),Ne.forEach(a),Ie=o(fe," function."),fe.forEach(a),ze=_(Ce),Q=l(Ce,"LI",{});var ue=i(Q);Le=o(ue,"Call "),oe=l(ue,"A",{href:!0});var y=i(oe);Ee=o(y,"train()"),y.forEach(a),Pe=o(ue," to finetune your model."),ue.forEach(a),Ce.forEach(a),qe=_(b),q(me.$$.fragment,b),ye=_(b),de=l(b,"P",{});var Ae=i(de);re=o(Ae,"Once training is completed, share your model to the Hub with the "),Te=l(Ae,"A",{href:!0});var Be=i(Te);ge=o(Be,"push_to_hub()"),Be.forEach(a),_e=o(Ae," method so everyone can use your model:"),Ae.forEach(a),ke=_(b),q(ne.$$.fragment,b),this.h()},h(){g(w,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM"),g(V,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Seq2SeqTrainingArguments"),g(v,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer"),g(ve,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Seq2SeqTrainer"),g(oe,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer.train"),g(Te,"href","/docs/transformers/v4.27.1/en/main_classes/trainer#transformers.Trainer.push_to_hub")},m(b,M){T(p,b,M),m(b,h,M),m(b,r,M),t(r,$),t(r,w),t(w,j),t(r,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,ve),t(ve,ce),t(W,je),t(W,we),t(we,xe),t(W,Ie),t(O,ze),t(O,Q),t(Q,Le),t(Q,oe),t(oe,Ee),t(Q,Pe),m(b,qe,M),T(me,b,M),m(b,ye,M),m(b,de,M),t(de,re),t(de,Te),t(Te,ge),t(de,_e),m(b,ke,M),T(ne,b,M),le=!0},p(b,M){const $e={};M&2&&($e.$$scope={dirty:M,ctx:b}),p.$set($e)},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(h),b&&a(r),b&&a(I),x(k,b),b&&a(F),b&&a(C),b&&a(B),b&&a(O),b&&a(qe),x(me,b),b&&a(ye),b&&a(de),b&&a(ke),x(ne,b)}}}function Or(R){let p,h;return p=new na({props:{$$slots:{default:[Ir]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Br(R){let p,h,r,$,w;return{c(){p=n("p"),h=s("If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),r=n("a"),$=s("here"),w=s("!"),this.h()},l(j){p=l(j,"P",{});var P=i(p);h=o(P,"If you aren\u2019t familiar with finetuning a model with Keras, take a look at the basic tutorial "),r=l(P,"A",{href:!0});var I=i(r);$=o(I,"here"),I.forEach(a),w=o(P,"!"),P.forEach(a),this.h()},h(){g(r,"href","../training#train-a-tensorflow-model-with-keras")},m(j,P){m(j,p,P),t(p,h),t(p,r),t(r,$),t(p,w)},d(j){j&&a(p)}}}function Nr(R){let p,h,r,$,w,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,ve,ce,je,we,xe,Ie,ze,Q,Le,oe,Ee,Pe,qe,me,ye,de,re,Te,ge,_e,ke,ne,le,b,M,$e,Se,Ce,se,be,Oe,he,Fe,fe,ie,Ne,ue,y,Ae,Be,Me,et,He;return p=new bs({props:{$$slots:{default:[Br]},$$scope:{ctx:R}}}),r=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>)`}}),be=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]'}}),Ae=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),h=s(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),E(r.$$.fragment),$=d(),w=n("p"),j=s("Then you can load T5 with "),P=n("a"),I=s("TFAutoModelForSeq2SeqLM"),k=s(":"),F=d(),E(C.$$.fragment),N=d(),B=n("p"),O=s("Convert your datasets to the "),D=n("code"),pe=s("tf.data.Dataset"),V=s(" format with "),L=n("a"),Z=s("prepare_tf_dataset()"),Y=s(":"),ee=d(),E(K.$$.fragment),H=d(),G=n("p"),u=s("Configure the model for training with "),v=n("a"),te=n("code"),U=s("compile"),ae=s(":"),W=d(),E(J.$$.fragment),ve=d(),ce=n("p"),je=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=n("a"),xe=s("Keras callbacks"),Ie=s("."),ze=d(),Q=n("p"),Le=s("Pass your "),oe=n("code"),Ee=s("compute_metrics"),Pe=s(" function to "),qe=n("a"),me=s("KerasMetricCallback"),ye=s(":"),de=d(),E(re.$$.fragment),Te=d(),ge=n("p"),_e=s("Specify where to push your model and tokenizer in the "),ke=n("a"),ne=s("PushToHubCallback"),le=s(":"),b=d(),E(M.$$.fragment),$e=d(),Se=n("p"),Ce=s("Then bundle your callbacks together:"),se=d(),E(be.$$.fragment),Oe=d(),he=n("p"),Fe=s("Finally, you\u2019re ready to start training your model! Call "),fe=n("a"),ie=n("code"),Ne=s("fit"),ue=s(" with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),y=d(),E(Ae.$$.fragment),Be=d(),Me=n("p"),et=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),h=o(c,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),q(r.$$.fragment,c),$=_(c),w=l(c,"P",{});var z=i(w);j=o(z,"Then you can load T5 with "),P=l(z,"A",{href:!0});var De=i(P);I=o(De,"TFAutoModelForSeq2SeqLM"),De.forEach(a),k=o(z,":"),z.forEach(a),F=_(c),q(C.$$.fragment,c),N=_(c),B=l(c,"P",{});var Ge=i(B);O=o(Ge,"Convert your datasets to the "),D=l(Ge,"CODE",{});var Xe=i(D);pe=o(Xe,"tf.data.Dataset"),Xe.forEach(a),V=o(Ge," format with "),L=l(Ge,"A",{href:!0});var nt=i(L);Z=o(nt,"prepare_tf_dataset()"),nt.forEach(a),Y=o(Ge,":"),Ge.forEach(a),ee=_(c),q(K.$$.fragment,c),H=_(c),G=l(c,"P",{});var Ve=i(G);u=o(Ve,"Configure the model for training with "),v=l(Ve,"A",{href:!0,rel:!0});var Ue=i(v);te=l(Ue,"CODE",{});var Je=i(te);U=o(Je,"compile"),Je.forEach(a),Ue.forEach(a),ae=o(Ve,":"),Ve.forEach(a),W=_(c),q(J.$$.fragment,c),ve=_(c),ce=l(c,"P",{});var Ye=i(ce);je=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=l(Ye,"A",{href:!0});var lt=i(we);xe=o(lt,"Keras callbacks"),lt.forEach(a),Ie=o(Ye,"."),Ye.forEach(a),ze=_(c),Q=l(c,"P",{});var Ke=i(Q);Le=o(Ke,"Pass your "),oe=l(Ke,"CODE",{});var it=i(oe);Ee=o(it,"compute_metrics"),it.forEach(a),Pe=o(Ke," function to "),qe=l(Ke,"A",{href:!0});var Re=i(qe);me=o(Re,"KerasMetricCallback"),Re.forEach(a),ye=o(Ke,":"),Ke.forEach(a),de=_(c),q(re.$$.fragment,c),Te=_(c),ge=l(c,"P",{});var We=i(ge);_e=o(We,"Specify where to push your model and tokenizer in the "),ke=l(We,"A",{href:!0});var pt=i(ke);ne=o(pt,"PushToHubCallback"),pt.forEach(a),le=o(We,":"),We.forEach(a),b=_(c),q(M.$$.fragment,c),$e=_(c),Se=l(c,"P",{});var ct=i(Se);Ce=o(ct,"Then bundle your callbacks together:"),ct.forEach(a),se=_(c),q(be.$$.fragment,c),Oe=_(c),he=l(c,"P",{});var tt=i(he);Fe=o(tt,"Finally, you\u2019re ready to start training your model! Call "),fe=l(tt,"A",{href:!0,rel:!0});var Kt=i(fe);ie=l(Kt,"CODE",{});var Wt=i(ie);Ne=o(Wt,"fit"),Wt.forEach(a),Kt.forEach(a),ue=o(tt," with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:"),tt.forEach(a),y=_(c),q(Ae.$$.fragment,c),Be=_(c),Me=l(c,"P",{});var St=i(Me);et=o(St,"Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!"),St.forEach(a),this.h()},h(){g(P,"href","/docs/transformers/v4.27.1/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM"),g(L,"href","/docs/transformers/v4.27.1/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(qe,"href","/docs/transformers/v4.27.1/en/main_classes/keras_callbacks#transformers.KerasMetricCallback"),g(ke,"href","/docs/transformers/v4.27.1/en/main_classes/keras_callbacks#transformers.PushToHubCallback"),g(fe,"href","https://keras.io/api/models/model_training_apis/#fit-method"),g(fe,"rel","nofollow")},m(c,z){T(p,c,z),m(c,h,z),T(r,c,z),m(c,$,z),m(c,w,z),t(w,j),t(w,P),t(P,I),t(w,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,ve,z),m(c,ce,z),t(ce,je),t(ce,we),t(we,xe),t(ce,Ie),m(c,ze,z),m(c,Q,z),t(Q,Le),t(Q,oe),t(oe,Ee),t(Q,Pe),t(Q,qe),t(qe,me),t(Q,ye),m(c,de,z),T(re,c,z),m(c,Te,z),m(c,ge,z),t(ge,_e),t(ge,ke),t(ke,ne),t(ge,le),m(c,b,z),T(M,c,z),m(c,$e,z),m(c,Se,z),t(Se,Ce),m(c,se,z),T(be,c,z),m(c,Oe,z),m(c,he,z),t(he,Fe),t(he,fe),t(fe,ie),t(ie,Ne),t(he,ue),m(c,y,z),T(Ae,c,z),m(c,Be,z),m(c,Me,z),t(Me,et),He=!0},p(c,z){const De={};z&2&&(De.$$scope={dirty:z,ctx:c}),p.$set(De)},i(c){He||(S(p.$$.fragment,c),S(r.$$.fragment,c),S(C.$$.fragment,c),S(K.$$.fragment,c),S(J.$$.fragment,c),S(re.$$.fragment,c),S(M.$$.fragment,c),S(be.$$.fragment,c),S(Ae.$$.fragment,c),He=!0)},o(c){A(p.$$.fragment,c),A(r.$$.fragment,c),A(C.$$.fragment,c),A(K.$$.fragment,c),A(J.$$.fragment,c),A(re.$$.fragment,c),A(M.$$.fragment,c),A(be.$$.fragment,c),A(Ae.$$.fragment,c),He=!1},d(c){x(p,c),c&&a(h),x(r,c),c&&a($),c&&a(w),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(ve),c&&a(ce),c&&a(ze),c&&a(Q),c&&a(de),x(re,c),c&&a(Te),c&&a(ge),c&&a(b),x(M,c),c&&a($e),c&&a(Se),c&&a(se),x(be,c),c&&a(Oe),c&&a(he),c&&a(y),x(Ae,c),c&&a(Be),c&&a(Me)}}}function Hr(R){let p,h;return p=new na({props:{$$slots:{default:[Nr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Gr(R){let p,h,r,$,w,j,P,I;return{c(){p=n("p"),h=s(`For a more in-depth example of how to finetune a model for summarization, take a look at the corresponding
`),r=n("a"),$=s("PyTorch notebook"),w=s(`
or `),j=n("a"),P=s("TensorFlow notebook"),I=s("."),this.h()},l(k){p=l(k,"P",{});var F=i(p);h=o(F,`For a more in-depth example of how to finetune a model for summarization, take a look at the corresponding
`),r=l(F,"A",{href:!0,rel:!0});var C=i(r);$=o(C,"PyTorch notebook"),C.forEach(a),w=o(F,`
or `),j=l(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(r,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb"),g(r,"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,h),t(p,r),t(r,$),t(p,w),t(p,j),t(j,P),t(p,I)},d(k){k&&a(p)}}}function Ur(R){let p,h,r,$,w,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=n("p"),h=s("Tokenize the text and return the "),r=n("code"),$=s("input_ids"),w=s(" as PyTorch tensors:"),j=d(),E(P.$$.fragment),I=d(),k=n("p"),F=s("Use the "),C=n("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=n("a"),D=s("Text Generation"),pe=s(" API."),V=d(),E(L.$$.fragment),Z=d(),Y=n("p"),ee=s("Decode the generated token ids back into text:"),K=d(),E(H.$$.fragment),this.h()},l(u){p=l(u,"P",{});var v=i(p);h=o(v,"Tokenize the text and return the "),r=l(v,"CODE",{});var te=i(r);$=o(te,"input_ids"),te.forEach(a),w=o(v," as PyTorch tensors:"),v.forEach(a),j=_(u),q(P.$$.fragment,u),I=_(u),k=l(u,"P",{});var U=i(k);F=o(U,"Use the "),C=l(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=l(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=l(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.27.1/en/main_classes/text_generation#transformers.GenerationMixin.generate"),g(O,"href","./main_classes/text_generation")},m(u,v){m(u,p,v),t(p,h),t(p,r),t(r,$),t(p,w),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,h;return p=new na({props:{$$slots:{default:[Ur]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Yr(R){let p,h,r,$,w,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=n("p"),h=s("Tokenize the text and return the "),r=n("code"),$=s("input_ids"),w=s(" as TensorFlow tensors:"),j=d(),E(P.$$.fragment),I=d(),k=n("p"),F=s("Use the "),C=n("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=n("a"),D=s("Text Generation"),pe=s(" API."),V=d(),E(L.$$.fragment),Z=d(),Y=n("p"),ee=s("Decode the generated token ids back into text:"),K=d(),E(H.$$.fragment),this.h()},l(u){p=l(u,"P",{});var v=i(p);h=o(v,"Tokenize the text and return the "),r=l(v,"CODE",{});var te=i(r);$=o(te,"input_ids"),te.forEach(a),w=o(v," as TensorFlow tensors:"),v.forEach(a),j=_(u),q(P.$$.fragment,u),I=_(u),k=l(u,"P",{});var U=i(k);F=o(U,"Use the "),C=l(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=l(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=l(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.27.1/en/main_classes/text_generation#transformers.TFGenerationMixin.generate"),g(O,"href","./main_classes/text_generation")},m(u,v){m(u,p,v),t(p,h),t(p,r),t(r,$),t(p,w),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,h;return p=new na({props:{$$slots:{default:[Yr]},$$scope:{ctx:R}}}),{c(){E(p.$$.fragment)},l(r){q(p.$$.fragment,r)},m(r,$){T(p,r,$),h=!0},p(r,$){const w={};$&2&&(w.$$scope={dirty:$,ctx:r}),p.$set(w)},i(r){h||(S(p.$$.fragment,r),h=!0)},o(r){A(p.$$.fragment,r),h=!1},d(r){x(p,r)}}}function Wr(R){let p,h,r,$,w,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,ve,ce,je,we,xe,Ie,ze,Q,Le,oe,Ee,Pe,qe,me,ye,de,re,Te,ge,_e,ke,ne,le,b,M,$e,Se,Ce,se,be,Oe,he,Fe,fe,ie,Ne,ue,y,Ae,Be,Me,et,He,c,z,De,Ge,Xe,nt,Ve,Ue,Je,Ye,lt,Ke,it,Re,We,pt,ct,tt,Kt,Wt,St,mt,dt,la,At,ys,ia,ks,Pa,at,vs,pa,js,Es,ca,qs,Ts,Ca,xt,Fa,Xt,Ss,Ma,st,ma,As,xs,zt,zs,ha,Ps,Cs,Fs,Pt,Ms,fa,Ls,Ds,La,Ct,Da,Qe,Is,ua,Os,Bs,da,Ns,Hs,_a,Gs,Us,Ia,Ft,Oa,ot,Rs,Vt,Ys,Ks,ga,Ws,Xs,Ba,_t,Na,ht,gt,$a,Mt,Vs,ba,Js,Ha,Ze,Qs,Lt,Zs,eo,Dt,to,ao,It,so,oo,Ga,Ot,Ua,$t,ro,Bt,no,lo,Ra,Nt,Ya,bt,io,wa,po,co,Ka,ft,wt,ya,Ht,mo,ka,ho,Wa,yt,Xa,kt,Va,ut,vt,va,Gt,fo,ja,uo,Ja,Jt,_o,Qa,Qt,go,Za,Ut,es,rt,$o,Zt,bo,wo,Ea,yo,ko,ts,Rt,as,jt,vo,qa,jo,Eo,ss,Et,os;return j=new ra({}),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"}}),_e=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 ra({}),Fe=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>)`}}),Me=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>)'}}),De=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>}`}}),At=new ra({}),xt=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)`}}),Ct=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`}}),Ft=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>)'}}),_t=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Lr],pytorch:[Fr]},$$scope:{ctx:R}}}),Mt=new ra({}),Ot=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>)`}}),Nt=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()}`}}),Ht=new ra({}),yt=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Hr],pytorch:[Or]},$$scope:{ctx:R}}}),kt=new bs({props:{$$slots:{default:[Gr]},$$scope:{ctx:R}}}),Gt=new ra({}),Ut=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>'}}),Rt=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>}]`}}),Et=new To({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Kr],pytorch:[Rr]},$$scope:{ctx:R}}}),{c(){p=n("meta"),h=d(),r=n("h1"),$=n("a"),w=n("span"),E(j.$$.fragment),P=d(),I=n("span"),k=s("Summarization"),F=d(),E(C.$$.fragment),N=d(),E(B.$$.fragment),O=d(),D=n("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=n("ul"),Z=n("li"),Y=s("Extractive: extract the most relevant information from a document."),ee=d(),K=n("li"),H=s("Abstractive: generate new text that captures the most relevant information."),G=d(),u=n("p"),v=s("This guide will show you how to:"),te=d(),U=n("ol"),ae=n("li"),W=s("Finetune "),J=n("a"),ve=s("T5"),ce=s(" on the California state bill subset of the "),je=n("a"),we=s("BillSum"),xe=s(" dataset for abstractive summarization."),Ie=d(),ze=n("li"),Q=s("Use your finetuned model for inference."),Le=d(),E(oe.$$.fragment),Ee=d(),Pe=n("p"),qe=s("Before you begin, make sure you have all the necessary libraries installed:"),me=d(),E(ye.$$.fragment),de=d(),re=n("p"),Te=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:"),ge=d(),E(_e.$$.fragment),ke=d(),ne=n("h2"),le=n("a"),b=n("span"),E(M.$$.fragment),$e=d(),Se=n("span"),Ce=s("Load BillSum dataset"),se=d(),be=n("p"),Oe=s("Start by loading the smaller California state bill subset of the BillSum dataset from the \u{1F917} Datasets library:"),he=d(),E(Fe.$$.fragment),fe=d(),ie=n("p"),Ne=s("Split the dataset into a train and test set with the "),ue=n("code"),y=s("train_test_split"),Ae=s(" method:"),Be=d(),E(Me.$$.fragment),et=d(),He=n("p"),c=s("Then take a look at an example:"),z=d(),E(De.$$.fragment),Ge=d(),Xe=n("p"),nt=s("There are two fields that you\u2019ll want to use:"),Ve=d(),Ue=n("ul"),Je=n("li"),Ye=n("code"),lt=s("text"),Ke=s(": the text of the bill which\u2019ll be the input to the model."),it=d(),Re=n("li"),We=n("code"),pt=s("summary"),ct=s(": a condensed version of "),tt=n("code"),Kt=s("text"),Wt=s(" which\u2019ll be the model target."),St=d(),mt=n("h2"),dt=n("a"),la=n("span"),E(At.$$.fragment),ys=d(),ia=n("span"),ks=s("Preprocess"),Pa=d(),at=n("p"),vs=s("The next step is to load a T5 tokenizer to process "),pa=n("code"),js=s("text"),Es=s(" and "),ca=n("code"),qs=s("summary"),Ts=s(":"),Ca=d(),E(xt.$$.fragment),Fa=d(),Xt=n("p"),Ss=s("The preprocessing function you want to create needs to:"),Ma=d(),st=n("ol"),ma=n("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(),zt=n("li"),zs=s("Use the keyword "),ha=n("code"),Ps=s("text_target"),Cs=s(" argument when tokenizing labels."),Fs=d(),Pt=n("li"),Ms=s("Truncate sequences to be no longer than the maximum length set by the "),fa=n("code"),Ls=s("max_length"),Ds=s(" parameter."),La=d(),E(Ct.$$.fragment),Da=d(),Qe=n("p"),Is=s("To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),ua=n("code"),Os=s("map"),Bs=s(" method. You can speed up the "),da=n("code"),Ns=s("map"),Hs=s(" function by setting "),_a=n("code"),Gs=s("batched=True"),Us=s(" to process multiple elements of the dataset at once:"),Ia=d(),E(Ft.$$.fragment),Oa=d(),ot=n("p"),Rs=s("Now create a batch of examples using "),Vt=n("a"),Ys=s("DataCollatorForSeq2Seq"),Ks=s(". It\u2019s more efficient to "),ga=n("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(_t.$$.fragment),Na=d(),ht=n("h2"),gt=n("a"),$a=n("span"),E(Mt.$$.fragment),Vs=d(),ba=n("span"),Js=s("Evaluate"),Ha=d(),Ze=n("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} "),Lt=n("a"),Zs=s("Evaluate"),eo=s(" library. For this task, load the "),Dt=n("a"),to=s("ROUGE"),ao=s(" metric (see the \u{1F917} Evaluate "),It=n("a"),so=s("quick tour"),oo=s(" to learn more about how to load and compute a metric):"),Ga=d(),E(Ot.$$.fragment),Ua=d(),$t=n("p"),ro=s("Then create a function that passes your predictions and labels to "),Bt=n("a"),no=s("compute"),lo=s(" to calculate the ROUGE metric:"),Ra=d(),E(Nt.$$.fragment),Ya=d(),bt=n("p"),io=s("Your "),wa=n("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(),ft=n("h2"),wt=n("a"),ya=n("span"),E(Ht.$$.fragment),mo=d(),ka=n("span"),ho=s("Train"),Wa=d(),E(yt.$$.fragment),Xa=d(),E(kt.$$.fragment),Va=d(),ut=n("h2"),vt=n("a"),va=n("span"),E(Gt.$$.fragment),fo=d(),ja=n("span"),uo=s("Inference"),Ja=d(),Jt=n("p"),_o=s("Great, now that you\u2019ve finetuned a model, you can use it for inference!"),Qa=d(),Qt=n("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(Ut.$$.fragment),es=d(),rt=n("p"),$o=s("The simplest way to try out your finetuned model for inference is to use it in a "),Zt=n("a"),bo=s("pipeline()"),wo=s(". Instantiate a "),Ea=n("code"),yo=s("pipeline"),ko=s(" for summarization with your model, and pass your text to it:"),ts=d(),E(Rt.$$.fragment),as=d(),jt=n("p"),vo=s("You can also manually replicate the results of the "),qa=n("code"),jo=s("pipeline"),Eo=s(" if you\u2019d like:"),ss=d(),E(Et.$$.fragment),this.h()},l(e){const f=Sr('[data-svelte="svelte-1phssyn"]',document.head);p=l(f,"META",{name:!0,content:!0}),f.forEach(a),h=_(e),r=l(e,"H1",{class:!0});var Yt=i(r);$=l(Yt,"A",{id:!0,class:!0,href:!0});var Ta=i($);w=l(Ta,"SPAN",{});var Sa=i(w);q(j.$$.fragment,Sa),Sa.forEach(a),Ta.forEach(a),P=_(Yt),I=l(Yt,"SPAN",{});var Aa=i(I);k=o(Aa,"Summarization"),Aa.forEach(a),Yt.forEach(a),F=_(e),q(C.$$.fragment,e),N=_(e),q(B.$$.fragment,e),O=_(e),D=l(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=l(e,"UL",{});var rs=i(L);Z=l(rs,"LI",{});var So=i(Z);Y=o(So,"Extractive: extract the most relevant information from a document."),So.forEach(a),ee=_(rs),K=l(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=l(e,"P",{});var xo=i(u);v=o(xo,"This guide will show you how to:"),xo.forEach(a),te=_(e),U=l(e,"OL",{});var ns=i(U);ae=l(ns,"LI",{});var ea=i(ae);W=o(ea,"Finetune "),J=l(ea,"A",{href:!0,rel:!0});var zo=i(J);ve=o(zo,"T5"),zo.forEach(a),ce=o(ea," on the California state bill subset of the "),je=l(ea,"A",{href:!0,rel:!0});var Po=i(je);we=o(Po,"BillSum"),Po.forEach(a),xe=o(ea," dataset for abstractive summarization."),ea.forEach(a),Ie=_(ns),ze=l(ns,"LI",{});var Co=i(ze);Q=o(Co,"Use your finetuned model for inference."),Co.forEach(a),ns.forEach(a),Le=_(e),q(oe.$$.fragment,e),Ee=_(e),Pe=l(e,"P",{});var Fo=i(Pe);qe=o(Fo,"Before you begin, make sure you have all the necessary libraries installed:"),Fo.forEach(a),me=_(e),q(ye.$$.fragment,e),de=_(e),re=l(e,"P",{});var Mo=i(re);Te=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),ge=_(e),q(_e.$$.fragment,e),ke=_(e),ne=l(e,"H2",{class:!0});var ls=i(ne);le=l(ls,"A",{id:!0,class:!0,href:!0});var Lo=i(le);b=l(Lo,"SPAN",{});var Do=i(b);q(M.$$.fragment,Do),Do.forEach(a),Lo.forEach(a),$e=_(ls),Se=l(ls,"SPAN",{});var Io=i(Se);Ce=o(Io,"Load BillSum dataset"),Io.forEach(a),ls.forEach(a),se=_(e),be=l(e,"P",{});var Oo=i(be);Oe=o(Oo,"Start by loading the smaller California state bill subset of the BillSum dataset from the \u{1F917} Datasets library:"),Oo.forEach(a),he=_(e),q(Fe.$$.fragment,e),fe=_(e),ie=l(e,"P",{});var is=i(ie);Ne=o(is,"Split the dataset into a train and test set with the "),ue=l(is,"CODE",{});var Bo=i(ue);y=o(Bo,"train_test_split"),Bo.forEach(a),Ae=o(is," method:"),is.forEach(a),Be=_(e),q(Me.$$.fragment,e),et=_(e),He=l(e,"P",{});var No=i(He);c=o(No,"Then take a look at an example:"),No.forEach(a),z=_(e),q(De.$$.fragment,e),Ge=_(e),Xe=l(e,"P",{});var Ho=i(Xe);nt=o(Ho,"There are two fields that you\u2019ll want to use:"),Ho.forEach(a),Ve=_(e),Ue=l(e,"UL",{});var ps=i(Ue);Je=l(ps,"LI",{});var qo=i(Je);Ye=l(qo,"CODE",{});var Go=i(Ye);lt=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),it=_(ps),Re=l(ps,"LI",{});var za=i(Re);We=l(za,"CODE",{});var Uo=i(We);pt=o(Uo,"summary"),Uo.forEach(a),ct=o(za,": a condensed version of "),tt=l(za,"CODE",{});var Ro=i(tt);Kt=o(Ro,"text"),Ro.forEach(a),Wt=o(za," which\u2019ll be the model target."),za.forEach(a),ps.forEach(a),St=_(e),mt=l(e,"H2",{class:!0});var cs=i(mt);dt=l(cs,"A",{id:!0,class:!0,href:!0});var Yo=i(dt);la=l(Yo,"SPAN",{});var Ko=i(la);q(At.$$.fragment,Ko),Ko.forEach(a),Yo.forEach(a),ys=_(cs),ia=l(cs,"SPAN",{});var Wo=i(ia);ks=o(Wo,"Preprocess"),Wo.forEach(a),cs.forEach(a),Pa=_(e),at=l(e,"P",{});var ta=i(at);vs=o(ta,"The next step is to load a T5 tokenizer to process "),pa=l(ta,"CODE",{});var Xo=i(pa);js=o(Xo,"text"),Xo.forEach(a),Es=o(ta," and "),ca=l(ta,"CODE",{});var Vo=i(ca);qs=o(Vo,"summary"),Vo.forEach(a),Ts=o(ta,":"),ta.forEach(a),Ca=_(e),q(xt.$$.fragment,e),Fa=_(e),Xt=l(e,"P",{});var Jo=i(Xt);Ss=o(Jo,"The preprocessing function you want to create needs to:"),Jo.forEach(a),Ma=_(e),st=l(e,"OL",{});var aa=i(st);ma=l(aa,"LI",{});var Qo=i(ma);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=_(aa),zt=l(aa,"LI",{});var ms=i(zt);zs=o(ms,"Use the keyword "),ha=l(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=_(aa),Pt=l(aa,"LI",{});var hs=i(Pt);Ms=o(hs,"Truncate sequences to be no longer than the maximum length set by the "),fa=l(hs,"CODE",{});var er=i(fa);Ls=o(er,"max_length"),er.forEach(a),Ds=o(hs," parameter."),hs.forEach(a),aa.forEach(a),La=_(e),q(Ct.$$.fragment,e),Da=_(e),Qe=l(e,"P",{});var qt=i(Qe);Is=o(qt,"To apply the preprocessing function over the entire dataset, use \u{1F917} Datasets "),ua=l(qt,"CODE",{});var tr=i(ua);Os=o(tr,"map"),tr.forEach(a),Bs=o(qt," method. You can speed up the "),da=l(qt,"CODE",{});var ar=i(da);Ns=o(ar,"map"),ar.forEach(a),Hs=o(qt," function by setting "),_a=l(qt,"CODE",{});var sr=i(_a);Gs=o(sr,"batched=True"),sr.forEach(a),Us=o(qt," to process multiple elements of the dataset at once:"),qt.forEach(a),Ia=_(e),q(Ft.$$.fragment,e),Oa=_(e),ot=l(e,"P",{});var sa=i(ot);Rs=o(sa,"Now create a batch of examples using "),Vt=l(sa,"A",{href:!0});var or=i(Vt);Ys=o(or,"DataCollatorForSeq2Seq"),or.forEach(a),Ks=o(sa,". It\u2019s more efficient to "),ga=l(sa,"EM",{});var rr=i(ga);Ws=o(rr,"dynamically pad"),rr.forEach(a),Xs=o(sa," the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length."),sa.forEach(a),Ba=_(e),q(_t.$$.fragment,e),Na=_(e),ht=l(e,"H2",{class:!0});var fs=i(ht);gt=l(fs,"A",{id:!0,class:!0,href:!0});var nr=i(gt);$a=l(nr,"SPAN",{});var lr=i($a);q(Mt.$$.fragment,lr),lr.forEach(a),nr.forEach(a),Vs=_(fs),ba=l(fs,"SPAN",{});var ir=i(ba);Js=o(ir,"Evaluate"),ir.forEach(a),fs.forEach(a),Ha=_(e),Ze=l(e,"P",{});var Tt=i(Ze);Qs=o(Tt,"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} "),Lt=l(Tt,"A",{href:!0,rel:!0});var pr=i(Lt);Zs=o(pr,"Evaluate"),pr.forEach(a),eo=o(Tt," library. For this task, load the "),Dt=l(Tt,"A",{href:!0,rel:!0});var cr=i(Dt);to=o(cr,"ROUGE"),cr.forEach(a),ao=o(Tt," metric (see the \u{1F917} Evaluate "),It=l(Tt,"A",{href:!0,rel:!0});var mr=i(It);so=o(mr,"quick tour"),mr.forEach(a),oo=o(Tt," to learn more about how to load and compute a metric):"),Tt.forEach(a),Ga=_(e),q(Ot.$$.fragment,e),Ua=_(e),$t=l(e,"P",{});var us=i($t);ro=o(us,"Then create a function that passes your predictions and labels to "),Bt=l(us,"A",{href:!0,rel:!0});var hr=i(Bt);no=o(hr,"compute"),hr.forEach(a),lo=o(us," to calculate the ROUGE metric:"),us.forEach(a),Ra=_(e),q(Nt.$$.fragment,e),Ya=_(e),bt=l(e,"P",{});var ds=i(bt);io=o(ds,"Your "),wa=l(ds,"CODE",{});var fr=i(wa);po=o(fr,"compute_metrics"),fr.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),ft=l(e,"H2",{class:!0});var _s=i(ft);wt=l(_s,"A",{id:!0,class:!0,href:!0});var ur=i(wt);ya=l(ur,"SPAN",{});var dr=i(ya);q(Ht.$$.fragment,dr),dr.forEach(a),ur.forEach(a),mo=_(_s),ka=l(_s,"SPAN",{});var _r=i(ka);ho=o(_r,"Train"),_r.forEach(a),_s.forEach(a),Wa=_(e),q(yt.$$.fragment,e),Xa=_(e),q(kt.$$.fragment,e),Va=_(e),ut=l(e,"H2",{class:!0});var gs=i(ut);vt=l(gs,"A",{id:!0,class:!0,href:!0});var gr=i(vt);va=l(gr,"SPAN",{});var $r=i(va);q(Gt.$$.fragment,$r),$r.forEach(a),gr.forEach(a),fo=_(gs),ja=l(gs,"SPAN",{});var br=i(ja);uo=o(br,"Inference"),br.forEach(a),gs.forEach(a),Ja=_(e),Jt=l(e,"P",{});var wr=i(Jt);_o=o(wr,"Great, now that you\u2019ve finetuned a model, you can use it for inference!"),wr.forEach(a),Qa=_(e),Qt=l(e,"P",{});var yr=i(Qt);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(Ut.$$.fragment,e),es=_(e),rt=l(e,"P",{});var oa=i(rt);$o=o(oa,"The simplest way to try out your finetuned model for inference is to use it in a "),Zt=l(oa,"A",{href:!0});var kr=i(Zt);bo=o(kr,"pipeline()"),kr.forEach(a),wo=o(oa,". Instantiate a "),Ea=l(oa,"CODE",{});var vr=i(Ea);yo=o(vr,"pipeline"),vr.forEach(a),ko=o(oa," for summarization with your model, and pass your text to it:"),oa.forEach(a),ts=_(e),q(Rt.$$.fragment,e),as=_(e),jt=l(e,"P",{});var $s=i(jt);vo=o($s,"You can also manually replicate the results of the "),qa=l($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(Et.$$.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(r,"class","relative group"),g(J,"href","https://huggingface.co/t5-small"),g(J,"rel","nofollow"),g(je,"href","https://huggingface.co/datasets/billsum"),g(je,"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(dt,"id","preprocess"),g(dt,"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(dt,"href","#preprocess"),g(mt,"class","relative group"),g(Vt,"href","/docs/transformers/v4.27.1/en/main_classes/data_collator#transformers.DataCollatorForSeq2Seq"),g(gt,"id","evaluate"),g(gt,"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(gt,"href","#evaluate"),g(ht,"class","relative group"),g(Lt,"href","https://huggingface.co/docs/evaluate/index"),g(Lt,"rel","nofollow"),g(Dt,"href","https://huggingface.co/spaces/evaluate-metric/rouge"),g(Dt,"rel","nofollow"),g(It,"href","https://huggingface.co/docs/evaluate/a_quick_tour"),g(It,"rel","nofollow"),g(Bt,"href","https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute"),g(Bt,"rel","nofollow"),g(wt,"id","train"),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","#train"),g(ft,"class","relative group"),g(vt,"id","inference"),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","#inference"),g(ut,"class","relative group"),g(Zt,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline")},m(e,f){t(document.head,p),m(e,h,f),m(e,r,f),t(r,$),t($,w),T(j,w,null),t(r,P),t(r,I),t(I,k),m(e,F,f),T(C,e,f),m(e,N,f),T(B,e,f),m(e,O,f),m(e,D,f),t(D,pe),m(e,V,f),m(e,L,f),t(L,Z),t(Z,Y),t(L,ee),t(L,K),t(K,H),m(e,G,f),m(e,u,f),t(u,v),m(e,te,f),m(e,U,f),t(U,ae),t(ae,W),t(ae,J),t(J,ve),t(ae,ce),t(ae,je),t(je,we),t(ae,xe),t(U,Ie),t(U,ze),t(ze,Q),m(e,Le,f),T(oe,e,f),m(e,Ee,f),m(e,Pe,f),t(Pe,qe),m(e,me,f),T(ye,e,f),m(e,de,f),m(e,re,f),t(re,Te),m(e,ge,f),T(_e,e,f),m(e,ke,f),m(e,ne,f),t(ne,le),t(le,b),T(M,b,null),t(ne,$e),t(ne,Se),t(Se,Ce),m(e,se,f),m(e,be,f),t(be,Oe),m(e,he,f),T(Fe,e,f),m(e,fe,f),m(e,ie,f),t(ie,Ne),t(ie,ue),t(ue,y),t(ie,Ae),m(e,Be,f),T(Me,e,f),m(e,et,f),m(e,He,f),t(He,c),m(e,z,f),T(De,e,f),m(e,Ge,f),m(e,Xe,f),t(Xe,nt),m(e,Ve,f),m(e,Ue,f),t(Ue,Je),t(Je,Ye),t(Ye,lt),t(Je,Ke),t(Ue,it),t(Ue,Re),t(Re,We),t(We,pt),t(Re,ct),t(Re,tt),t(tt,Kt),t(Re,Wt),m(e,St,f),m(e,mt,f),t(mt,dt),t(dt,la),T(At,la,null),t(mt,ys),t(mt,ia),t(ia,ks),m(e,Pa,f),m(e,at,f),t(at,vs),t(at,pa),t(pa,js),t(at,Es),t(at,ca),t(ca,qs),t(at,Ts),m(e,Ca,f),T(xt,e,f),m(e,Fa,f),m(e,Xt,f),t(Xt,Ss),m(e,Ma,f),m(e,st,f),t(st,ma),t(ma,As),t(st,xs),t(st,zt),t(zt,zs),t(zt,ha),t(ha,Ps),t(zt,Cs),t(st,Fs),t(st,Pt),t(Pt,Ms),t(Pt,fa),t(fa,Ls),t(Pt,Ds),m(e,La,f),T(Ct,e,f),m(e,Da,f),m(e,Qe,f),t(Qe,Is),t(Qe,ua),t(ua,Os),t(Qe,Bs),t(Qe,da),t(da,Ns),t(Qe,Hs),t(Qe,_a),t(_a,Gs),t(Qe,Us),m(e,Ia,f),T(Ft,e,f),m(e,Oa,f),m(e,ot,f),t(ot,Rs),t(ot,Vt),t(Vt,Ys),t(ot,Ks),t(ot,ga),t(ga,Ws),t(ot,Xs),m(e,Ba,f),T(_t,e,f),m(e,Na,f),m(e,ht,f),t(ht,gt),t(gt,$a),T(Mt,$a,null),t(ht,Vs),t(ht,ba),t(ba,Js),m(e,Ha,f),m(e,Ze,f),t(Ze,Qs),t(Ze,Lt),t(Lt,Zs),t(Ze,eo),t(Ze,Dt),t(Dt,to),t(Ze,ao),t(Ze,It),t(It,so),t(Ze,oo),m(e,Ga,f),T(Ot,e,f),m(e,Ua,f),m(e,$t,f),t($t,ro),t($t,Bt),t(Bt,no),t($t,lo),m(e,Ra,f),T(Nt,e,f),m(e,Ya,f),m(e,bt,f),t(bt,io),t(bt,wa),t(wa,po),t(bt,co),m(e,Ka,f),m(e,ft,f),t(ft,wt),t(wt,ya),T(Ht,ya,null),t(ft,mo),t(ft,ka),t(ka,ho),m(e,Wa,f),T(yt,e,f),m(e,Xa,f),T(kt,e,f),m(e,Va,f),m(e,ut,f),t(ut,vt),t(vt,va),T(Gt,va,null),t(ut,fo),t(ut,ja),t(ja,uo),m(e,Ja,f),m(e,Jt,f),t(Jt,_o),m(e,Qa,f),m(e,Qt,f),t(Qt,go),m(e,Za,f),T(Ut,e,f),m(e,es,f),m(e,rt,f),t(rt,$o),t(rt,Zt),t(Zt,bo),t(rt,wo),t(rt,Ea),t(Ea,yo),t(rt,ko),m(e,ts,f),T(Rt,e,f),m(e,as,f),m(e,jt,f),t(jt,vo),t(jt,qa),t(qa,jo),t(jt,Eo),m(e,ss,f),T(Et,e,f),os=!0},p(e,[f]){const Yt={};f&2&&(Yt.$$scope={dirty:f,ctx:e}),oe.$set(Yt);const Ta={};f&2&&(Ta.$$scope={dirty:f,ctx:e}),_t.$set(Ta);const Sa={};f&2&&(Sa.$$scope={dirty:f,ctx:e}),yt.$set(Sa);const Aa={};f&2&&(Aa.$$scope={dirty:f,ctx:e}),kt.$set(Aa);const xa={};f&2&&(xa.$$scope={dirty:f,ctx:e}),Et.$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(_e.$$.fragment,e),S(M.$$.fragment,e),S(Fe.$$.fragment,e),S(Me.$$.fragment,e),S(De.$$.fragment,e),S(At.$$.fragment,e),S(xt.$$.fragment,e),S(Ct.$$.fragment,e),S(Ft.$$.fragment,e),S(_t.$$.fragment,e),S(Mt.$$.fragment,e),S(Ot.$$.fragment,e),S(Nt.$$.fragment,e),S(Ht.$$.fragment,e),S(yt.$$.fragment,e),S(kt.$$.fragment,e),S(Gt.$$.fragment,e),S(Ut.$$.fragment,e),S(Rt.$$.fragment,e),S(Et.$$.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(_e.$$.fragment,e),A(M.$$.fragment,e),A(Fe.$$.fragment,e),A(Me.$$.fragment,e),A(De.$$.fragment,e),A(At.$$.fragment,e),A(xt.$$.fragment,e),A(Ct.$$.fragment,e),A(Ft.$$.fragment,e),A(_t.$$.fragment,e),A(Mt.$$.fragment,e),A(Ot.$$.fragment,e),A(Nt.$$.fragment,e),A(Ht.$$.fragment,e),A(yt.$$.fragment,e),A(kt.$$.fragment,e),A(Gt.$$.fragment,e),A(Ut.$$.fragment,e),A(Rt.$$.fragment,e),A(Et.$$.fragment,e),os=!1},d(e){a(p),e&&a(h),e&&a(r),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(Le),x(oe,e),e&&a(Ee),e&&a(Pe),e&&a(me),x(ye,e),e&&a(de),e&&a(re),e&&a(ge),x(_e,e),e&&a(ke),e&&a(ne),x(M),e&&a(se),e&&a(be),e&&a(he),x(Fe,e),e&&a(fe),e&&a(ie),e&&a(Be),x(Me,e),e&&a(et),e&&a(He),e&&a(z),x(De,e),e&&a(Ge),e&&a(Xe),e&&a(Ve),e&&a(Ue),e&&a(St),e&&a(mt),x(At),e&&a(Pa),e&&a(at),e&&a(Ca),x(xt,e),e&&a(Fa),e&&a(Xt),e&&a(Ma),e&&a(st),e&&a(La),x(Ct,e),e&&a(Da),e&&a(Qe),e&&a(Ia),x(Ft,e),e&&a(Oa),e&&a(ot),e&&a(Ba),x(_t,e),e&&a(Na),e&&a(ht),x(Mt),e&&a(Ha),e&&a(Ze),e&&a(Ga),x(Ot,e),e&&a(Ua),e&&a($t),e&&a(Ra),x(Nt,e),e&&a(Ya),e&&a(bt),e&&a(Ka),e&&a(ft),x(Ht),e&&a(Wa),x(yt,e),e&&a(Xa),x(kt,e),e&&a(Va),e&&a(ut),x(Gt),e&&a(Ja),e&&a(Jt),e&&a(Qa),e&&a(Qt),e&&a(Za),x(Ut,e),e&&a(es),e&&a(rt),e&&a(ts),x(Rt,e),e&&a(as),e&&a(jt),e&&a(ss),x(Et,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};
