import{S as Fh,i as Rh,s as Hh,e as a,k as h,w as _,t as s,M as Mh,c as o,d as r,m,a as i,x as d,h as l,b as p,F as t,g as u,y as v,L as Gh,q as g,o as y,B as w}from"../chunks/vendor-4833417e.js";import{I as R}from"../chunks/IconCopyLink-4b81c553.js";import{C as $}from"../chunks/CodeBlock-6a3d1b46.js";import{C as jh}from"../chunks/CodeBlockFw-27a176a0.js";import"../chunks/CopyButton-dacfbfaf.js";function Bh(pi){let q,ft,z,P,pr,ge,ui,ur,hi,Ca,b,mi,ct,fi,ci,ye,_i,di,we,vi,gi,Ee,yi,wi,Da,I,Ei,$e,$i,bi,be,xi,zi,Na,_t,Ti,Oa,L,ki,xe,Ai,Pi,ze,qi,Ii,ja,S,Li,Te,Si,Ui,ke,Ci,Di,Fa,H,K,hr,Ae,Ni,mr,Oi,Ra,Q,ji,fr,Fi,Ri,Ha,Pe,Ma,dt,Hi,Ga,Z,cr,Mi,Gi,f,_r,vt,Bi,Ji,dr,gt,Wi,Xi,vr,yt,Yi,Vi,gr,wt,Ki,Qi,yr,Et,Zi,es,wr,$t,ts,rs,Er,bt,as,os,$r,xt,is,ss,br,zt,ls,ns,xr,Tt,ps,us,zr,kt,hs,ms,Tr,At,fs,cs,kr,Pt,_s,ds,Ar,qt,vs,gs,Pr,It,ys,ws,qr,Lt,Es,$s,Ir,St,bs,xs,Lr,Ut,zs,Ts,Sr,Ct,ks,As,Ur,Dt,Ps,qs,Cr,Nt,Is,Ls,Dr,Ot,Ss,Us,Nr,jt,Cs,Ds,Or,Ft,Ns,Os,jr,Rt,js,Fs,Fr,Ht,Rs,Hs,Rr,Mt,Ms,Ba,Gt,Gs,Ja,qe,Wa,Bt,Bs,Xa,Ie,Ya,M,ee,Hr,Le,Js,Mr,Ws,Va,E,Xs,Se,Ys,Vs,Ue,Ks,Qs,Ce,Zs,el,De,tl,rl,Gr,al,ol,Ka,Ne,Qa,G,te,Br,Oe,il,Jr,sl,Za,re,ll,je,nl,pl,eo,ae,Fe,ul,Wr,hl,ml,fl,Re,cl,Xr,_l,dl,to,He,ro,oe,vl,Me,Yr,gl,yl,ao,B,ie,Vr,Ge,wl,Kr,El,oo,x,$l,Be,bl,xl,Je,zl,Tl,Qr,kl,Al,Zr,Pl,ql,io,U,Il,We,ea,Ll,Sl,ta,Ul,Cl,so,Xe,lo,J,se,ra,Ye,Dl,aa,Nl,no,le,Ol,Ve,jl,Fl,po,Ke,uo,T,Rl,oa,Hl,Ml,ia,Gl,Bl,sa,Jl,Wl,ho,Qe,mo,Jt,Xl,fo,Ze,co,Wt,Yl,_o,et,vo,W,ne,la,tt,Vl,na,Kl,go,Xt,Ql,yo,C,pe,pa,Zl,en,ua,tn,rn,an,Yt,ha,on,sn,ln,Vt,ma,nn,pn,wo,Kt,un,Eo,rt,$o,X,ue,fa,at,hn,ca,mn,bo,Qt,fn,xo,D,_a,da,cn,_n,va,ga,dn,vn,ya,wa,gn,zo,ot,To,N,yn,Ea,wn,En,$a,$n,bn,ko,it,Ao,Y,he,ba,st,xn,xa,zn,Po,Zt,Tn,qo,k,kn,za,An,Pn,Ta,qn,In,ka,Ln,Sn,Io,lt,Lo,me,Un,Aa,Cn,Dn,So,nt,Uo,V,fe,Pa,pt,Nn,qa,On,Co,ce,jn,ut,Fn,Rn,Do,ht,No,O,Hn,Ia,Mn,Gn,La,Bn,Jn,Oo,_e,Wn,Sa,Xn,Yn,jo,er,Vn,Fo,mt,Ro;return ge=new R({}),Ae=new R({}),Pe=new $({props:{code:`git clone https://github.com/huggingface/transformers
cd transformers
pip install .`,highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/transformers
<span class="hljs-built_in">cd</span> transformers
pip install .`}}),qe=new $({props:{code:"git checkout tags/v3.5.1",highlighted:"git checkout tags/v3.5.1"}}),Ie=new $({props:{code:"pip install -r requirements.txt",highlighted:"pip install -r requirements.txt"}}),Le=new R({}),Ne=new jh({props:{group1:{id:"pt",code:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`},group2:{id:"tf",code:`python examples/tensorflow/summarization/run_summarization.py  \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --output_dir /tmp/tst-summarization  \\
    --per_device_train_batch_size 8 \\
    --per_device_eval_batch_size 16 \\
    --num_train_epochs 3 \\
    --do_train \\
    --do_eval`,highlighted:`python examples/tensorflow/summarization/run_summarization.py  \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --output_dir /tmp/tst-summarization  \\
    --per_device_train_batch_size 8 \\
    --per_device_eval_batch_size 16 \\
    --num_train_epochs 3 \\
    --do_train \\
    --do_eval`}}}),Oe=new R({}),He=new $({props:{code:`python -m torch.distributed.launch \\
    --nproc_per_node 8 pytorch/summarization/run_summarization.py \\
    --fp16 \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`,highlighted:`python -m torch.distributed.launch \\
    --nproc_per_node 8 pytorch/summarization/run_summarization.py \\
    --fp16 \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`}}),Ge=new R({}),Xe=new jh({props:{group1:{id:"pt",code:`python xla_spawn.py --num_cores 8 \\
    summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`,highlighted:`python xla_spawn.py --num_cores 8 \\
    summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`},group2:{id:"tf",code:`python run_summarization.py  \\
    --tpu name_of_tpu_resource \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --output_dir /tmp/tst-summarization  \\
    --per_device_train_batch_size 8 \\
    --per_device_eval_batch_size 16 \\
    --num_train_epochs 3 \\
    --do_train \\
    --do_eval`,highlighted:`python run_summarization.py  \\
    --tpu name_of_tpu_resource \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --output_dir /tmp/tst-summarization  \\
    --per_device_train_batch_size 8 \\
    --per_device_eval_batch_size 16 \\
    --num_train_epochs 3 \\
    --do_train \\
    --do_eval`}}}),Ye=new R({}),Ke=new $({props:{code:"pip install accelerate",highlighted:"pip install accelerate"}}),Qe=new $({props:{code:"accelerate config",highlighted:"accelerate config"}}),Ze=new $({props:{code:"accelerate test",highlighted:'accelerate <span class="hljs-built_in">test</span>'}}),et=new $({props:{code:`accelerate launch run_summarization_no_trainer.py \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir ~/tmp/tst-summarization`,highlighted:`accelerate launch run_summarization_no_trainer.py \\
    --model_name_or_path t5-small \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir ~/tmp/tst-summarization`}}),tt=new R({}),rt=new $({props:{code:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --train_file path_to_csv_or_jsonlines_file \\
    --validation_file path_to_csv_or_jsonlines_file \\
    --text_column text_column_name \\
    --summary_column summary_column_name \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --overwrite_output_dir \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --train_file path_to_csv_or_jsonlines_file \\
    --validation_file path_to_csv_or_jsonlines_file \\
    --text_column text_column_name \\
    --summary_column summary_column_name \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --overwrite_output_dir \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --predict_with_generate`}}),at=new R({}),ot=new $({props:{code:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --max_train_samples 50 \\
    --max_eval_samples 50 \\
    --max_predict_samples 50 \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py \\
    --model_name_or_path t5-small \\
    --max_train_samples 50 \\
    --max_eval_samples 50 \\
    --max_predict_samples 50 \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`}}),it=new $({props:{code:"examples/pytorch/summarization/run_summarization.py -h",highlighted:"examples/pytorch/summarization/run_summarization.py -h"}}),st=new R({}),lt=new $({props:{code:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --output_dir previous_output_dir \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --output_dir previous_output_dir \\
    --predict_with_generate`}}),nt=new $({props:{code:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --resume_from_checkpoint path_to_specific_checkpoint \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --resume_from_checkpoint path_to_specific_checkpoint \\
    --predict_with_generate`}}),pt=new R({}),ht=new $({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}}),mt=new $({props:{code:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config "3.0.0" \\
    --source_prefix "summarize: " \\
    --push_to_hub \\
    --push_to_hub_model_id finetuned-t5-cnn_dailymail \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`,highlighted:`python examples/pytorch/summarization/run_summarization.py
    --model_name_or_path t5-small \\
    --do_train \\
    --do_eval \\
    --dataset_name cnn_dailymail \\
    --dataset_config <span class="hljs-string">&quot;3.0.0&quot;</span> \\
    --source_prefix <span class="hljs-string">&quot;summarize: &quot;</span> \\
    --push_to_hub \\
    --push_to_hub_model_id finetuned-t5-cnn_dailymail \\
    --output_dir /tmp/tst-summarization \\
    --per_device_train_batch_size=4 \\
    --per_device_eval_batch_size=4 \\
    --overwrite_output_dir \\
    --predict_with_generate`}}),{c(){q=a("meta"),ft=h(),z=a("h1"),P=a("a"),pr=a("span"),_(ge.$$.fragment),ui=h(),ur=a("span"),hi=s("Train with a script"),Ca=h(),b=a("p"),mi=s("Along with the \u{1F917} Transformers "),ct=a("a"),fi=s("notebooks"),ci=s(", there are also example scripts demonstrating how to train a model for a task with "),ye=a("a"),_i=s("PyTorch"),di=s(", "),we=a("a"),vi=s("TensorFlow"),gi=s(", or "),Ee=a("a"),yi=s("JAX/Flax"),wi=s("."),Da=h(),I=a("p"),Ei=s("You will also find scripts we\u2019ve used in our "),$e=a("a"),$i=s("research projects"),bi=s(" and "),be=a("a"),xi=s("legacy examples"),zi=s(" which are mostly community contributed. These scripts are not actively maintained and require a specific version of \u{1F917} Transformers that will most likely be incompatible with the latest version of the library."),Na=h(),_t=a("p"),Ti=s("The example scripts are not expected to work out-of-the-box on every problem, and you may need to adapt the script to the problem you\u2019re trying to solve. To help you with this, most of the scripts fully expose how data is preprocessed, allowing you to edit it as necessary for your use case."),Oa=h(),L=a("p"),ki=s("For any feature you\u2019d like to implement in an example script, please discuss it on the "),xe=a("a"),Ai=s("forum"),Pi=s(" or in an "),ze=a("a"),qi=s("issue"),Ii=s(" before submitting a Pull Request. While we welcome bug fixes, it is unlikely we will merge a Pull Request that adds more functionality at the cost of readability."),ja=h(),S=a("p"),Li=s("This guide will show you how to run an example summarization training script in "),Te=a("a"),Si=s("PyTorch"),Ui=s(" and "),ke=a("a"),Ci=s("TensorFlow"),Di=s(". All examples are expected to work with both frameworks unless otherwise specified."),Fa=h(),H=a("h2"),K=a("a"),hr=a("span"),_(Ae.$$.fragment),Ni=h(),mr=a("span"),Oi=s("Setup"),Ra=h(),Q=a("p"),ji=s("To successfully run the latest version of the example scripts, you have to "),fr=a("strong"),Fi=s("install \u{1F917} Transformers from source"),Ri=s(" in a new virtual environment:"),Ha=h(),_(Pe.$$.fragment),Ma=h(),dt=a("p"),Hi=s("For older versions of the example scripts, click on the toggle below:"),Ga=h(),Z=a("details"),cr=a("summary"),Mi=s("Examples for older versions of \u{1F917} Transformers"),Gi=h(),f=a("ul"),_r=a("li"),vt=a("a"),Bi=s("v4.5.1"),Ji=h(),dr=a("li"),gt=a("a"),Wi=s("v4.4.2"),Xi=h(),vr=a("li"),yt=a("a"),Yi=s("v4.3.3"),Vi=h(),gr=a("li"),wt=a("a"),Ki=s("v4.2.2"),Qi=h(),yr=a("li"),Et=a("a"),Zi=s("v4.1.1"),es=h(),wr=a("li"),$t=a("a"),ts=s("v4.0.1"),rs=h(),Er=a("li"),bt=a("a"),as=s("v3.5.1"),os=h(),$r=a("li"),xt=a("a"),is=s("v3.4.0"),ss=h(),br=a("li"),zt=a("a"),ls=s("v3.3.1"),ns=h(),xr=a("li"),Tt=a("a"),ps=s("v3.2.0"),us=h(),zr=a("li"),kt=a("a"),hs=s("v3.1.0"),ms=h(),Tr=a("li"),At=a("a"),fs=s("v3.0.2"),cs=h(),kr=a("li"),Pt=a("a"),_s=s("v2.11.0"),ds=h(),Ar=a("li"),qt=a("a"),vs=s("v2.10.0"),gs=h(),Pr=a("li"),It=a("a"),ys=s("v2.9.1"),ws=h(),qr=a("li"),Lt=a("a"),Es=s("v2.8.0"),$s=h(),Ir=a("li"),St=a("a"),bs=s("v2.7.0"),xs=h(),Lr=a("li"),Ut=a("a"),zs=s("v2.6.0"),Ts=h(),Sr=a("li"),Ct=a("a"),ks=s("v2.5.1"),As=h(),Ur=a("li"),Dt=a("a"),Ps=s("v2.4.0"),qs=h(),Cr=a("li"),Nt=a("a"),Is=s("v2.3.0"),Ls=h(),Dr=a("li"),Ot=a("a"),Ss=s("v2.2.0"),Us=h(),Nr=a("li"),jt=a("a"),Cs=s("v2.1.1"),Ds=h(),Or=a("li"),Ft=a("a"),Ns=s("v2.0.0"),Os=h(),jr=a("li"),Rt=a("a"),js=s("v1.2.0"),Fs=h(),Fr=a("li"),Ht=a("a"),Rs=s("v1.1.0"),Hs=h(),Rr=a("li"),Mt=a("a"),Ms=s("v1.0.0"),Ba=h(),Gt=a("p"),Gs=s("Then switch your current clone of \u{1F917} Transformers to a specific version, like v3.5.1 for example:"),Ja=h(),_(qe.$$.fragment),Wa=h(),Bt=a("p"),Bs=s("After you\u2019ve setup the correct library version, navigate to the example folder of your choice and install the example specific requirements:"),Xa=h(),_(Ie.$$.fragment),Ya=h(),M=a("h2"),ee=a("a"),Hr=a("span"),_(Le.$$.fragment),Js=h(),Mr=a("span"),Ws=s("Run a script"),Va=h(),E=a("p"),Xs=s("The example script downloads and preprocesses a dataset from the \u{1F917} "),Se=a("a"),Ys=s("Datasets"),Vs=s(" library. Then the script fine-tunes a dataset with the "),Ue=a("a"),Ks=s("Trainer"),Qs=s(" on an architecture that supports summarization. The following example shows how to fine-tune "),Ce=a("a"),Zs=s("T5-small"),el=s(" on the "),De=a("a"),tl=s("CNN/DailyMail"),rl=s(" dataset. The T5 model requires an additional "),Gr=a("code"),al=s("source_prefix"),ol=s(" argument due to how it was trained. This prompt lets T5 know this is a summarization task."),Ka=h(),_(Ne.$$.fragment),Qa=h(),G=a("h2"),te=a("a"),Br=a("span"),_(Oe.$$.fragment),il=h(),Jr=a("span"),sl=s("Distributed training and mixed precision"),Za=h(),re=a("p"),ll=s("The "),je=a("a"),nl=s("Trainer"),pl=s(" supports distributed training and mixed precision, which means you can also use it in a script. To enable both of these features:"),eo=h(),ae=a("ul"),Fe=a("li"),ul=s("Add the "),Wr=a("code"),hl=s("fp16"),ml=s(" argument to enable mixed precision."),fl=h(),Re=a("li"),cl=s("Set the number of GPUs to use with the "),Xr=a("code"),_l=s("nproc_per_node"),dl=s(" argument."),to=h(),_(He.$$.fragment),ro=h(),oe=a("p"),vl=s("TensorFlow scripts utilize a "),Me=a("a"),Yr=a("code"),gl=s("MirroredStrategy"),yl=s(" for distributed training, and you don\u2019t need to add any additional arguments to the training script. The TensorFlow script will use multiple GPUs by default if they are available."),ao=h(),B=a("h2"),ie=a("a"),Vr=a("span"),_(Ge.$$.fragment),wl=h(),Kr=a("span"),El=s("Run a script on a TPU"),oo=h(),x=a("p"),$l=s("Tensor Processing Units (TPUs) are specifically designed to accelerate performance. PyTorch supports TPUs with the "),Be=a("a"),bl=s("XLA"),xl=s(" deep learning compiler (see "),Je=a("a"),zl=s("here"),Tl=s(" for more details). To use a TPU, launch the "),Qr=a("code"),kl=s("xla_spawn.py"),Al=s(" script and use the "),Zr=a("code"),Pl=s("num_cores"),ql=s(" argument to set the number of TPU cores you want to use."),io=h(),U=a("p"),Il=s("TensorFlow scripts utilize a "),We=a("a"),ea=a("code"),Ll=s("TPUStrategy"),Sl=s(" for training on TPUs. To use a TPU, pass the name of the TPU resource to the "),ta=a("code"),Ul=s("tpu"),Cl=s(" argument."),so=h(),_(Xe.$$.fragment),lo=h(),J=a("h2"),se=a("a"),ra=a("span"),_(Ye.$$.fragment),Dl=h(),aa=a("span"),Nl=s("Run a script with \u{1F917} Accelerate"),no=h(),le=a("p"),Ol=s("\u{1F917} "),Ve=a("a"),jl=s("Accelerate"),Fl=s(" is a PyTorch-only library that offers a unified method for training a model on several types of setups (CPU-only, multiple GPUs, TPUs) while maintaining complete visibility into the PyTorch training loop. Make sure you have \u{1F917} Accelerate installed if you don\u2019t already have it:"),po=h(),_(Ke.$$.fragment),uo=h(),T=a("p"),Rl=s("Instead of the "),oa=a("code"),Hl=s("run_summarization.py"),Ml=s(" script, you need to use the "),ia=a("code"),Gl=s("run_summarization_no_trainer.py"),Bl=s(" script. \u{1F917} Accelerate supported scripts will have a "),sa=a("code"),Jl=s("task_no_trainer.py"),Wl=s(" file in the folder. Begin by running the following command to create and save a configuration file:"),ho=h(),_(Qe.$$.fragment),mo=h(),Jt=a("p"),Xl=s("Test your setup to make sure it is configured correctly:"),fo=h(),_(Ze.$$.fragment),co=h(),Wt=a("p"),Yl=s("Now you are ready to launch the training:"),_o=h(),_(et.$$.fragment),vo=h(),W=a("h2"),ne=a("a"),la=a("span"),_(tt.$$.fragment),Vl=h(),na=a("span"),Kl=s("Use a custom dataset"),go=h(),Xt=a("p"),Ql=s("The summarization script supports custom datasets as long as they are a CSV or JSON Line file. When you use your own dataset, you need to specify several additional arguments:"),yo=h(),C=a("ul"),pe=a("li"),pa=a("code"),Zl=s("train_file"),en=s(" and "),ua=a("code"),tn=s("validation_file"),rn=s(" specify the path to your training and validation files."),an=h(),Yt=a("li"),ha=a("code"),on=s("text_column"),sn=s(" is the input text to summarize."),ln=h(),Vt=a("li"),ma=a("code"),nn=s("summary_column"),pn=s(" is the target text to output."),wo=h(),Kt=a("p"),un=s("A summarization script using a custom dataset would look like this:"),Eo=h(),_(rt.$$.fragment),$o=h(),X=a("h2"),ue=a("a"),fa=a("span"),_(at.$$.fragment),hn=h(),ca=a("span"),mn=s("Test a script"),bo=h(),Qt=a("p"),fn=s("It is often a good idea to run your script on a smaller number of dataset examples to ensure everything works as expected before committing to an entire dataset which may take hours to complete. Use the following arguments to truncate the dataset to a maximum number of samples:"),xo=h(),D=a("ul"),_a=a("li"),da=a("code"),cn=s("max_train_samples"),_n=h(),va=a("li"),ga=a("code"),dn=s("max_eval_samples"),vn=h(),ya=a("li"),wa=a("code"),gn=s("max_predict_samples"),zo=h(),_(ot.$$.fragment),To=h(),N=a("p"),yn=s("Not all example scripts support the "),Ea=a("code"),wn=s("max_predict_samples"),En=s(" argument. If you aren\u2019t sure whether your script supports this argument, add the "),$a=a("code"),$n=s("-h"),bn=s(" argument to check:"),ko=h(),_(it.$$.fragment),Ao=h(),Y=a("h2"),he=a("a"),ba=a("span"),_(st.$$.fragment),xn=h(),xa=a("span"),zn=s("Resume training from checkpoint"),Po=h(),Zt=a("p"),Tn=s("Another helpful option to enable is resuming training from a previous checkpoint. This will ensure you can pick up where you left off without starting over if your training gets interrupted. There are two methods to resume training from a checkpoint."),qo=h(),k=a("p"),kn=s("The first method uses the "),za=a("code"),An=s("output_dir previous_output_dir"),Pn=s(" argument to resume training from the latest checkpoint stored in "),Ta=a("code"),qn=s("output_dir"),In=s(". In this case, you should remove "),ka=a("code"),Ln=s("overwrite_output_dir"),Sn=s(":"),Io=h(),_(lt.$$.fragment),Lo=h(),me=a("p"),Un=s("The second method uses the "),Aa=a("code"),Cn=s("resume_from_checkpoint path_to_specific_checkpoint"),Dn=s(" argument to resume training from a specific checkpoint folder."),So=h(),_(nt.$$.fragment),Uo=h(),V=a("h2"),fe=a("a"),Pa=a("span"),_(pt.$$.fragment),Nn=h(),qa=a("span"),On=s("Share your model"),Co=h(),ce=a("p"),jn=s("All scripts can upload your final model to the "),ut=a("a"),Fn=s("Model Hub"),Rn=s(". Make sure you are logged into Hugging Face before you begin:"),Do=h(),_(ht.$$.fragment),No=h(),O=a("p"),Hn=s("Then add the "),Ia=a("code"),Mn=s("push_to_hub"),Gn=s(" argument to the script. This argument will create a repository with your Hugging Face username and the folder name specified in "),La=a("code"),Bn=s("output_dir"),Jn=s("."),Oo=h(),_e=a("p"),Wn=s("To give your repository a specific name, use the "),Sa=a("code"),Xn=s("push_to_hub_model_id"),Yn=s(" argument to add it. The repository will be automatically listed under your namespace."),jo=h(),er=a("p"),Vn=s("The following example shows how to upload a model with a specific repository name:"),Fo=h(),_(mt.$$.fragment),this.h()},l(e){const n=Mh('[data-svelte="svelte-1phssyn"]',document.head);q=o(n,"META",{name:!0,content:!0}),n.forEach(r),ft=m(e),z=o(e,"H1",{class:!0});var Ho=i(z);P=o(Ho,"A",{id:!0,class:!0,href:!0});var Zn=i(P);pr=o(Zn,"SPAN",{});var ep=i(pr);d(ge.$$.fragment,ep),ep.forEach(r),Zn.forEach(r),ui=m(Ho),ur=o(Ho,"SPAN",{});var tp=i(ur);hi=l(tp,"Train with a script"),tp.forEach(r),Ho.forEach(r),Ca=m(e),b=o(e,"P",{});var j=i(b);mi=l(j,"Along with the \u{1F917} Transformers "),ct=o(j,"A",{href:!0});var rp=i(ct);fi=l(rp,"notebooks"),rp.forEach(r),ci=l(j,", there are also example scripts demonstrating how to train a model for a task with "),ye=o(j,"A",{href:!0,rel:!0});var ap=i(ye);_i=l(ap,"PyTorch"),ap.forEach(r),di=l(j,", "),we=o(j,"A",{href:!0,rel:!0});var op=i(we);vi=l(op,"TensorFlow"),op.forEach(r),gi=l(j,", or "),Ee=o(j,"A",{href:!0,rel:!0});var ip=i(Ee);yi=l(ip,"JAX/Flax"),ip.forEach(r),wi=l(j,"."),j.forEach(r),Da=m(e),I=o(e,"P",{});var tr=i(I);Ei=l(tr,"You will also find scripts we\u2019ve used in our "),$e=o(tr,"A",{href:!0,rel:!0});var sp=i($e);$i=l(sp,"research projects"),sp.forEach(r),bi=l(tr," and "),be=o(tr,"A",{href:!0,rel:!0});var lp=i(be);xi=l(lp,"legacy examples"),lp.forEach(r),zi=l(tr," which are mostly community contributed. These scripts are not actively maintained and require a specific version of \u{1F917} Transformers that will most likely be incompatible with the latest version of the library."),tr.forEach(r),Na=m(e),_t=o(e,"P",{});var np=i(_t);Ti=l(np,"The example scripts are not expected to work out-of-the-box on every problem, and you may need to adapt the script to the problem you\u2019re trying to solve. To help you with this, most of the scripts fully expose how data is preprocessed, allowing you to edit it as necessary for your use case."),np.forEach(r),Oa=m(e),L=o(e,"P",{});var rr=i(L);ki=l(rr,"For any feature you\u2019d like to implement in an example script, please discuss it on the "),xe=o(rr,"A",{href:!0,rel:!0});var pp=i(xe);Ai=l(pp,"forum"),pp.forEach(r),Pi=l(rr," or in an "),ze=o(rr,"A",{href:!0,rel:!0});var up=i(ze);qi=l(up,"issue"),up.forEach(r),Ii=l(rr," before submitting a Pull Request. While we welcome bug fixes, it is unlikely we will merge a Pull Request that adds more functionality at the cost of readability."),rr.forEach(r),ja=m(e),S=o(e,"P",{});var ar=i(S);Li=l(ar,"This guide will show you how to run an example summarization training script in "),Te=o(ar,"A",{href:!0,rel:!0});var hp=i(Te);Si=l(hp,"PyTorch"),hp.forEach(r),Ui=l(ar," and "),ke=o(ar,"A",{href:!0,rel:!0});var mp=i(ke);Ci=l(mp,"TensorFlow"),mp.forEach(r),Di=l(ar,". All examples are expected to work with both frameworks unless otherwise specified."),ar.forEach(r),Fa=m(e),H=o(e,"H2",{class:!0});var Mo=i(H);K=o(Mo,"A",{id:!0,class:!0,href:!0});var fp=i(K);hr=o(fp,"SPAN",{});var cp=i(hr);d(Ae.$$.fragment,cp),cp.forEach(r),fp.forEach(r),Ni=m(Mo),mr=o(Mo,"SPAN",{});var _p=i(mr);Oi=l(_p,"Setup"),_p.forEach(r),Mo.forEach(r),Ra=m(e),Q=o(e,"P",{});var Go=i(Q);ji=l(Go,"To successfully run the latest version of the example scripts, you have to "),fr=o(Go,"STRONG",{});var dp=i(fr);Fi=l(dp,"install \u{1F917} Transformers from source"),dp.forEach(r),Ri=l(Go," in a new virtual environment:"),Go.forEach(r),Ha=m(e),d(Pe.$$.fragment,e),Ma=m(e),dt=o(e,"P",{});var vp=i(dt);Hi=l(vp,"For older versions of the example scripts, click on the toggle below:"),vp.forEach(r),Ga=m(e),Z=o(e,"DETAILS",{});var Bo=i(Z);cr=o(Bo,"SUMMARY",{});var gp=i(cr);Mi=l(gp,"Examples for older versions of \u{1F917} Transformers"),gp.forEach(r),Gi=m(Bo),f=o(Bo,"UL",{});var c=i(f);_r=o(c,"LI",{});var yp=i(_r);vt=o(yp,"A",{href:!0});var wp=i(vt);Bi=l(wp,"v4.5.1"),wp.forEach(r),yp.forEach(r),Ji=m(c),dr=o(c,"LI",{});var Ep=i(dr);gt=o(Ep,"A",{href:!0});var $p=i(gt);Wi=l($p,"v4.4.2"),$p.forEach(r),Ep.forEach(r),Xi=m(c),vr=o(c,"LI",{});var bp=i(vr);yt=o(bp,"A",{href:!0});var xp=i(yt);Yi=l(xp,"v4.3.3"),xp.forEach(r),bp.forEach(r),Vi=m(c),gr=o(c,"LI",{});var zp=i(gr);wt=o(zp,"A",{href:!0});var Tp=i(wt);Ki=l(Tp,"v4.2.2"),Tp.forEach(r),zp.forEach(r),Qi=m(c),yr=o(c,"LI",{});var kp=i(yr);Et=o(kp,"A",{href:!0});var Ap=i(Et);Zi=l(Ap,"v4.1.1"),Ap.forEach(r),kp.forEach(r),es=m(c),wr=o(c,"LI",{});var Pp=i(wr);$t=o(Pp,"A",{href:!0});var qp=i($t);ts=l(qp,"v4.0.1"),qp.forEach(r),Pp.forEach(r),rs=m(c),Er=o(c,"LI",{});var Ip=i(Er);bt=o(Ip,"A",{href:!0});var Lp=i(bt);as=l(Lp,"v3.5.1"),Lp.forEach(r),Ip.forEach(r),os=m(c),$r=o(c,"LI",{});var Sp=i($r);xt=o(Sp,"A",{href:!0});var Up=i(xt);is=l(Up,"v3.4.0"),Up.forEach(r),Sp.forEach(r),ss=m(c),br=o(c,"LI",{});var Cp=i(br);zt=o(Cp,"A",{href:!0});var Dp=i(zt);ls=l(Dp,"v3.3.1"),Dp.forEach(r),Cp.forEach(r),ns=m(c),xr=o(c,"LI",{});var Np=i(xr);Tt=o(Np,"A",{href:!0});var Op=i(Tt);ps=l(Op,"v3.2.0"),Op.forEach(r),Np.forEach(r),us=m(c),zr=o(c,"LI",{});var jp=i(zr);kt=o(jp,"A",{href:!0});var Fp=i(kt);hs=l(Fp,"v3.1.0"),Fp.forEach(r),jp.forEach(r),ms=m(c),Tr=o(c,"LI",{});var Rp=i(Tr);At=o(Rp,"A",{href:!0});var Hp=i(At);fs=l(Hp,"v3.0.2"),Hp.forEach(r),Rp.forEach(r),cs=m(c),kr=o(c,"LI",{});var Mp=i(kr);Pt=o(Mp,"A",{href:!0});var Gp=i(Pt);_s=l(Gp,"v2.11.0"),Gp.forEach(r),Mp.forEach(r),ds=m(c),Ar=o(c,"LI",{});var Bp=i(Ar);qt=o(Bp,"A",{href:!0});var Jp=i(qt);vs=l(Jp,"v2.10.0"),Jp.forEach(r),Bp.forEach(r),gs=m(c),Pr=o(c,"LI",{});var Wp=i(Pr);It=o(Wp,"A",{href:!0});var Xp=i(It);ys=l(Xp,"v2.9.1"),Xp.forEach(r),Wp.forEach(r),ws=m(c),qr=o(c,"LI",{});var Yp=i(qr);Lt=o(Yp,"A",{href:!0});var Vp=i(Lt);Es=l(Vp,"v2.8.0"),Vp.forEach(r),Yp.forEach(r),$s=m(c),Ir=o(c,"LI",{});var Kp=i(Ir);St=o(Kp,"A",{href:!0});var Qp=i(St);bs=l(Qp,"v2.7.0"),Qp.forEach(r),Kp.forEach(r),xs=m(c),Lr=o(c,"LI",{});var Zp=i(Lr);Ut=o(Zp,"A",{href:!0});var eu=i(Ut);zs=l(eu,"v2.6.0"),eu.forEach(r),Zp.forEach(r),Ts=m(c),Sr=o(c,"LI",{});var tu=i(Sr);Ct=o(tu,"A",{href:!0});var ru=i(Ct);ks=l(ru,"v2.5.1"),ru.forEach(r),tu.forEach(r),As=m(c),Ur=o(c,"LI",{});var au=i(Ur);Dt=o(au,"A",{href:!0});var ou=i(Dt);Ps=l(ou,"v2.4.0"),ou.forEach(r),au.forEach(r),qs=m(c),Cr=o(c,"LI",{});var iu=i(Cr);Nt=o(iu,"A",{href:!0});var su=i(Nt);Is=l(su,"v2.3.0"),su.forEach(r),iu.forEach(r),Ls=m(c),Dr=o(c,"LI",{});var lu=i(Dr);Ot=o(lu,"A",{href:!0});var nu=i(Ot);Ss=l(nu,"v2.2.0"),nu.forEach(r),lu.forEach(r),Us=m(c),Nr=o(c,"LI",{});var pu=i(Nr);jt=o(pu,"A",{href:!0});var uu=i(jt);Cs=l(uu,"v2.1.1"),uu.forEach(r),pu.forEach(r),Ds=m(c),Or=o(c,"LI",{});var hu=i(Or);Ft=o(hu,"A",{href:!0});var mu=i(Ft);Ns=l(mu,"v2.0.0"),mu.forEach(r),hu.forEach(r),Os=m(c),jr=o(c,"LI",{});var fu=i(jr);Rt=o(fu,"A",{href:!0});var cu=i(Rt);js=l(cu,"v1.2.0"),cu.forEach(r),fu.forEach(r),Fs=m(c),Fr=o(c,"LI",{});var _u=i(Fr);Ht=o(_u,"A",{href:!0});var du=i(Ht);Rs=l(du,"v1.1.0"),du.forEach(r),_u.forEach(r),Hs=m(c),Rr=o(c,"LI",{});var vu=i(Rr);Mt=o(vu,"A",{href:!0});var gu=i(Mt);Ms=l(gu,"v1.0.0"),gu.forEach(r),vu.forEach(r),c.forEach(r),Bo.forEach(r),Ba=m(e),Gt=o(e,"P",{});var yu=i(Gt);Gs=l(yu,"Then switch your current clone of \u{1F917} Transformers to a specific version, like v3.5.1 for example:"),yu.forEach(r),Ja=m(e),d(qe.$$.fragment,e),Wa=m(e),Bt=o(e,"P",{});var wu=i(Bt);Bs=l(wu,"After you\u2019ve setup the correct library version, navigate to the example folder of your choice and install the example specific requirements:"),wu.forEach(r),Xa=m(e),d(Ie.$$.fragment,e),Ya=m(e),M=o(e,"H2",{class:!0});var Jo=i(M);ee=o(Jo,"A",{id:!0,class:!0,href:!0});var Eu=i(ee);Hr=o(Eu,"SPAN",{});var $u=i(Hr);d(Le.$$.fragment,$u),$u.forEach(r),Eu.forEach(r),Js=m(Jo),Mr=o(Jo,"SPAN",{});var bu=i(Mr);Ws=l(bu,"Run a script"),bu.forEach(r),Jo.forEach(r),Va=m(e),E=o(e,"P",{});var A=i(E);Xs=l(A,"The example script downloads and preprocesses a dataset from the \u{1F917} "),Se=o(A,"A",{href:!0,rel:!0});var xu=i(Se);Ys=l(xu,"Datasets"),xu.forEach(r),Vs=l(A," library. Then the script fine-tunes a dataset with the "),Ue=o(A,"A",{href:!0,rel:!0});var zu=i(Ue);Ks=l(zu,"Trainer"),zu.forEach(r),Qs=l(A," on an architecture that supports summarization. The following example shows how to fine-tune "),Ce=o(A,"A",{href:!0,rel:!0});var Tu=i(Ce);Zs=l(Tu,"T5-small"),Tu.forEach(r),el=l(A," on the "),De=o(A,"A",{href:!0,rel:!0});var ku=i(De);tl=l(ku,"CNN/DailyMail"),ku.forEach(r),rl=l(A," dataset. The T5 model requires an additional "),Gr=o(A,"CODE",{});var Au=i(Gr);al=l(Au,"source_prefix"),Au.forEach(r),ol=l(A," argument due to how it was trained. This prompt lets T5 know this is a summarization task."),A.forEach(r),Ka=m(e),d(Ne.$$.fragment,e),Qa=m(e),G=o(e,"H2",{class:!0});var Wo=i(G);te=o(Wo,"A",{id:!0,class:!0,href:!0});var Pu=i(te);Br=o(Pu,"SPAN",{});var qu=i(Br);d(Oe.$$.fragment,qu),qu.forEach(r),Pu.forEach(r),il=m(Wo),Jr=o(Wo,"SPAN",{});var Iu=i(Jr);sl=l(Iu,"Distributed training and mixed precision"),Iu.forEach(r),Wo.forEach(r),Za=m(e),re=o(e,"P",{});var Xo=i(re);ll=l(Xo,"The "),je=o(Xo,"A",{href:!0,rel:!0});var Lu=i(je);nl=l(Lu,"Trainer"),Lu.forEach(r),pl=l(Xo," supports distributed training and mixed precision, which means you can also use it in a script. To enable both of these features:"),Xo.forEach(r),eo=m(e),ae=o(e,"UL",{});var Yo=i(ae);Fe=o(Yo,"LI",{});var Vo=i(Fe);ul=l(Vo,"Add the "),Wr=o(Vo,"CODE",{});var Su=i(Wr);hl=l(Su,"fp16"),Su.forEach(r),ml=l(Vo," argument to enable mixed precision."),Vo.forEach(r),fl=m(Yo),Re=o(Yo,"LI",{});var Ko=i(Re);cl=l(Ko,"Set the number of GPUs to use with the "),Xr=o(Ko,"CODE",{});var Uu=i(Xr);_l=l(Uu,"nproc_per_node"),Uu.forEach(r),dl=l(Ko," argument."),Ko.forEach(r),Yo.forEach(r),to=m(e),d(He.$$.fragment,e),ro=m(e),oe=o(e,"P",{});var Qo=i(oe);vl=l(Qo,"TensorFlow scripts utilize a "),Me=o(Qo,"A",{href:!0,rel:!0});var Cu=i(Me);Yr=o(Cu,"CODE",{});var Du=i(Yr);gl=l(Du,"MirroredStrategy"),Du.forEach(r),Cu.forEach(r),yl=l(Qo," for distributed training, and you don\u2019t need to add any additional arguments to the training script. The TensorFlow script will use multiple GPUs by default if they are available."),Qo.forEach(r),ao=m(e),B=o(e,"H2",{class:!0});var Zo=i(B);ie=o(Zo,"A",{id:!0,class:!0,href:!0});var Nu=i(ie);Vr=o(Nu,"SPAN",{});var Ou=i(Vr);d(Ge.$$.fragment,Ou),Ou.forEach(r),Nu.forEach(r),wl=m(Zo),Kr=o(Zo,"SPAN",{});var ju=i(Kr);El=l(ju,"Run a script on a TPU"),ju.forEach(r),Zo.forEach(r),oo=m(e),x=o(e,"P",{});var F=i(x);$l=l(F,"Tensor Processing Units (TPUs) are specifically designed to accelerate performance. PyTorch supports TPUs with the "),Be=o(F,"A",{href:!0,rel:!0});var Fu=i(Be);bl=l(Fu,"XLA"),Fu.forEach(r),xl=l(F," deep learning compiler (see "),Je=o(F,"A",{href:!0,rel:!0});var Ru=i(Je);zl=l(Ru,"here"),Ru.forEach(r),Tl=l(F," for more details). To use a TPU, launch the "),Qr=o(F,"CODE",{});var Hu=i(Qr);kl=l(Hu,"xla_spawn.py"),Hu.forEach(r),Al=l(F," script and use the "),Zr=o(F,"CODE",{});var Mu=i(Zr);Pl=l(Mu,"num_cores"),Mu.forEach(r),ql=l(F," argument to set the number of TPU cores you want to use."),F.forEach(r),io=m(e),U=o(e,"P",{});var or=i(U);Il=l(or,"TensorFlow scripts utilize a "),We=o(or,"A",{href:!0,rel:!0});var Gu=i(We);ea=o(Gu,"CODE",{});var Bu=i(ea);Ll=l(Bu,"TPUStrategy"),Bu.forEach(r),Gu.forEach(r),Sl=l(or," for training on TPUs. To use a TPU, pass the name of the TPU resource to the "),ta=o(or,"CODE",{});var Ju=i(ta);Ul=l(Ju,"tpu"),Ju.forEach(r),Cl=l(or," argument."),or.forEach(r),so=m(e),d(Xe.$$.fragment,e),lo=m(e),J=o(e,"H2",{class:!0});var ei=i(J);se=o(ei,"A",{id:!0,class:!0,href:!0});var Wu=i(se);ra=o(Wu,"SPAN",{});var Xu=i(ra);d(Ye.$$.fragment,Xu),Xu.forEach(r),Wu.forEach(r),Dl=m(ei),aa=o(ei,"SPAN",{});var Yu=i(aa);Nl=l(Yu,"Run a script with \u{1F917} Accelerate"),Yu.forEach(r),ei.forEach(r),no=m(e),le=o(e,"P",{});var ti=i(le);Ol=l(ti,"\u{1F917} "),Ve=o(ti,"A",{href:!0,rel:!0});var Vu=i(Ve);jl=l(Vu,"Accelerate"),Vu.forEach(r),Fl=l(ti," is a PyTorch-only library that offers a unified method for training a model on several types of setups (CPU-only, multiple GPUs, TPUs) while maintaining complete visibility into the PyTorch training loop. Make sure you have \u{1F917} Accelerate installed if you don\u2019t already have it:"),ti.forEach(r),po=m(e),d(Ke.$$.fragment,e),uo=m(e),T=o(e,"P",{});var de=i(T);Rl=l(de,"Instead of the "),oa=o(de,"CODE",{});var Ku=i(oa);Hl=l(Ku,"run_summarization.py"),Ku.forEach(r),Ml=l(de," script, you need to use the "),ia=o(de,"CODE",{});var Qu=i(ia);Gl=l(Qu,"run_summarization_no_trainer.py"),Qu.forEach(r),Bl=l(de," script. \u{1F917} Accelerate supported scripts will have a "),sa=o(de,"CODE",{});var Zu=i(sa);Jl=l(Zu,"task_no_trainer.py"),Zu.forEach(r),Wl=l(de," file in the folder. Begin by running the following command to create and save a configuration file:"),de.forEach(r),ho=m(e),d(Qe.$$.fragment,e),mo=m(e),Jt=o(e,"P",{});var eh=i(Jt);Xl=l(eh,"Test your setup to make sure it is configured correctly:"),eh.forEach(r),fo=m(e),d(Ze.$$.fragment,e),co=m(e),Wt=o(e,"P",{});var th=i(Wt);Yl=l(th,"Now you are ready to launch the training:"),th.forEach(r),_o=m(e),d(et.$$.fragment,e),vo=m(e),W=o(e,"H2",{class:!0});var ri=i(W);ne=o(ri,"A",{id:!0,class:!0,href:!0});var rh=i(ne);la=o(rh,"SPAN",{});var ah=i(la);d(tt.$$.fragment,ah),ah.forEach(r),rh.forEach(r),Vl=m(ri),na=o(ri,"SPAN",{});var oh=i(na);Kl=l(oh,"Use a custom dataset"),oh.forEach(r),ri.forEach(r),go=m(e),Xt=o(e,"P",{});var ih=i(Xt);Ql=l(ih,"The summarization script supports custom datasets as long as they are a CSV or JSON Line file. When you use your own dataset, you need to specify several additional arguments:"),ih.forEach(r),yo=m(e),C=o(e,"UL",{});var ir=i(C);pe=o(ir,"LI",{});var Ua=i(pe);pa=o(Ua,"CODE",{});var sh=i(pa);Zl=l(sh,"train_file"),sh.forEach(r),en=l(Ua," and "),ua=o(Ua,"CODE",{});var lh=i(ua);tn=l(lh,"validation_file"),lh.forEach(r),rn=l(Ua," specify the path to your training and validation files."),Ua.forEach(r),an=m(ir),Yt=o(ir,"LI",{});var Kn=i(Yt);ha=o(Kn,"CODE",{});var nh=i(ha);on=l(nh,"text_column"),nh.forEach(r),sn=l(Kn," is the input text to summarize."),Kn.forEach(r),ln=m(ir),Vt=o(ir,"LI",{});var Qn=i(Vt);ma=o(Qn,"CODE",{});var ph=i(ma);nn=l(ph,"summary_column"),ph.forEach(r),pn=l(Qn," is the target text to output."),Qn.forEach(r),ir.forEach(r),wo=m(e),Kt=o(e,"P",{});var uh=i(Kt);un=l(uh,"A summarization script using a custom dataset would look like this:"),uh.forEach(r),Eo=m(e),d(rt.$$.fragment,e),$o=m(e),X=o(e,"H2",{class:!0});var ai=i(X);ue=o(ai,"A",{id:!0,class:!0,href:!0});var hh=i(ue);fa=o(hh,"SPAN",{});var mh=i(fa);d(at.$$.fragment,mh),mh.forEach(r),hh.forEach(r),hn=m(ai),ca=o(ai,"SPAN",{});var fh=i(ca);mn=l(fh,"Test a script"),fh.forEach(r),ai.forEach(r),bo=m(e),Qt=o(e,"P",{});var ch=i(Qt);fn=l(ch,"It is often a good idea to run your script on a smaller number of dataset examples to ensure everything works as expected before committing to an entire dataset which may take hours to complete. Use the following arguments to truncate the dataset to a maximum number of samples:"),ch.forEach(r),xo=m(e),D=o(e,"UL",{});var sr=i(D);_a=o(sr,"LI",{});var _h=i(_a);da=o(_h,"CODE",{});var dh=i(da);cn=l(dh,"max_train_samples"),dh.forEach(r),_h.forEach(r),_n=m(sr),va=o(sr,"LI",{});var vh=i(va);ga=o(vh,"CODE",{});var gh=i(ga);dn=l(gh,"max_eval_samples"),gh.forEach(r),vh.forEach(r),vn=m(sr),ya=o(sr,"LI",{});var yh=i(ya);wa=o(yh,"CODE",{});var wh=i(wa);gn=l(wh,"max_predict_samples"),wh.forEach(r),yh.forEach(r),sr.forEach(r),zo=m(e),d(ot.$$.fragment,e),To=m(e),N=o(e,"P",{});var lr=i(N);yn=l(lr,"Not all example scripts support the "),Ea=o(lr,"CODE",{});var Eh=i(Ea);wn=l(Eh,"max_predict_samples"),Eh.forEach(r),En=l(lr," argument. If you aren\u2019t sure whether your script supports this argument, add the "),$a=o(lr,"CODE",{});var $h=i($a);$n=l($h,"-h"),$h.forEach(r),bn=l(lr," argument to check:"),lr.forEach(r),ko=m(e),d(it.$$.fragment,e),Ao=m(e),Y=o(e,"H2",{class:!0});var oi=i(Y);he=o(oi,"A",{id:!0,class:!0,href:!0});var bh=i(he);ba=o(bh,"SPAN",{});var xh=i(ba);d(st.$$.fragment,xh),xh.forEach(r),bh.forEach(r),xn=m(oi),xa=o(oi,"SPAN",{});var zh=i(xa);zn=l(zh,"Resume training from checkpoint"),zh.forEach(r),oi.forEach(r),Po=m(e),Zt=o(e,"P",{});var Th=i(Zt);Tn=l(Th,"Another helpful option to enable is resuming training from a previous checkpoint. This will ensure you can pick up where you left off without starting over if your training gets interrupted. There are two methods to resume training from a checkpoint."),Th.forEach(r),qo=m(e),k=o(e,"P",{});var ve=i(k);kn=l(ve,"The first method uses the "),za=o(ve,"CODE",{});var kh=i(za);An=l(kh,"output_dir previous_output_dir"),kh.forEach(r),Pn=l(ve," argument to resume training from the latest checkpoint stored in "),Ta=o(ve,"CODE",{});var Ah=i(Ta);qn=l(Ah,"output_dir"),Ah.forEach(r),In=l(ve,". In this case, you should remove "),ka=o(ve,"CODE",{});var Ph=i(ka);Ln=l(Ph,"overwrite_output_dir"),Ph.forEach(r),Sn=l(ve,":"),ve.forEach(r),Io=m(e),d(lt.$$.fragment,e),Lo=m(e),me=o(e,"P",{});var ii=i(me);Un=l(ii,"The second method uses the "),Aa=o(ii,"CODE",{});var qh=i(Aa);Cn=l(qh,"resume_from_checkpoint path_to_specific_checkpoint"),qh.forEach(r),Dn=l(ii," argument to resume training from a specific checkpoint folder."),ii.forEach(r),So=m(e),d(nt.$$.fragment,e),Uo=m(e),V=o(e,"H2",{class:!0});var si=i(V);fe=o(si,"A",{id:!0,class:!0,href:!0});var Ih=i(fe);Pa=o(Ih,"SPAN",{});var Lh=i(Pa);d(pt.$$.fragment,Lh),Lh.forEach(r),Ih.forEach(r),Nn=m(si),qa=o(si,"SPAN",{});var Sh=i(qa);On=l(Sh,"Share your model"),Sh.forEach(r),si.forEach(r),Co=m(e),ce=o(e,"P",{});var li=i(ce);jn=l(li,"All scripts can upload your final model to the "),ut=o(li,"A",{href:!0,rel:!0});var Uh=i(ut);Fn=l(Uh,"Model Hub"),Uh.forEach(r),Rn=l(li,". Make sure you are logged into Hugging Face before you begin:"),li.forEach(r),Do=m(e),d(ht.$$.fragment,e),No=m(e),O=o(e,"P",{});var nr=i(O);Hn=l(nr,"Then add the "),Ia=o(nr,"CODE",{});var Ch=i(Ia);Mn=l(Ch,"push_to_hub"),Ch.forEach(r),Gn=l(nr," argument to the script. This argument will create a repository with your Hugging Face username and the folder name specified in "),La=o(nr,"CODE",{});var Dh=i(La);Bn=l(Dh,"output_dir"),Dh.forEach(r),Jn=l(nr,"."),nr.forEach(r),Oo=m(e),_e=o(e,"P",{});var ni=i(_e);Wn=l(ni,"To give your repository a specific name, use the "),Sa=o(ni,"CODE",{});var Nh=i(Sa);Xn=l(Nh,"push_to_hub_model_id"),Nh.forEach(r),Yn=l(ni," argument to add it. The repository will be automatically listed under your namespace."),ni.forEach(r),jo=m(e),er=o(e,"P",{});var Oh=i(er);Vn=l(Oh,"The following example shows how to upload a model with a specific repository name:"),Oh.forEach(r),Fo=m(e),d(mt.$$.fragment,e),this.h()},h(){p(q,"name","hf:doc:metadata"),p(q,"content",JSON.stringify(Jh)),p(P,"id","train-with-a-script"),p(P,"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"),p(P,"href","#train-with-a-script"),p(z,"class","relative group"),p(ct,"href","./noteboks/README"),p(ye,"href","https://github.com/huggingface/transformers/tree/master/examples/pytorch"),p(ye,"rel","nofollow"),p(we,"href","https://github.com/huggingface/transformers/tree/master/examples/tensorflow"),p(we,"rel","nofollow"),p(Ee,"href","https://github.com/huggingface/transformers/tree/master/examples/flax"),p(Ee,"rel","nofollow"),p($e,"href","https://github.com/huggingface/transformers/tree/master/examples/research_projects"),p($e,"rel","nofollow"),p(be,"href","https://github.com/huggingface/transformers/tree/master/examples/legacy"),p(be,"rel","nofollow"),p(xe,"href","https://discuss.huggingface.co/"),p(xe,"rel","nofollow"),p(ze,"href","https://github.com/huggingface/transformers/issues"),p(ze,"rel","nofollow"),p(Te,"href","https://github.com/huggingface/transformers/tree/master/examples/pytorch/summarization"),p(Te,"rel","nofollow"),p(ke,"href","https://github.com/huggingface/transformers/tree/master/examples/tensorflow/summarization"),p(ke,"rel","nofollow"),p(K,"id","setup"),p(K,"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"),p(K,"href","#setup"),p(H,"class","relative group"),p(vt,"href","https://github.com/huggingface/transformers/tree/v4.5.1/examples"),p(gt,"href","https://github.com/huggingface/transformers/tree/v4.4.2/examples"),p(yt,"href","https://github.com/huggingface/transformers/tree/v4.3.3/examples"),p(wt,"href","https://github.com/huggingface/transformers/tree/v4.2.2/examples"),p(Et,"href","https://github.com/huggingface/transformers/tree/v4.1.1/examples"),p($t,"href","https://github.com/huggingface/transformers/tree/v4.0.1/examples"),p(bt,"href","https://github.com/huggingface/transformers/tree/v3.5.1/examples"),p(xt,"href","https://github.com/huggingface/transformers/tree/v3.4.0/examples"),p(zt,"href","https://github.com/huggingface/transformers/tree/v3.3.1/examples"),p(Tt,"href","https://github.com/huggingface/transformers/tree/v3.2.0/examples"),p(kt,"href","https://github.com/huggingface/transformers/tree/v3.1.0/examples"),p(At,"href","https://github.com/huggingface/transformers/tree/v3.0.2/examples"),p(Pt,"href","https://github.com/huggingface/transformers/tree/v2.11.0/examples"),p(qt,"href","https://github.com/huggingface/transformers/tree/v2.10.0/examples"),p(It,"href","https://github.com/huggingface/transformers/tree/v2.9.1/examples"),p(Lt,"href","https://github.com/huggingface/transformers/tree/v2.8.0/examples"),p(St,"href","https://github.com/huggingface/transformers/tree/v2.7.0/examples"),p(Ut,"href","https://github.com/huggingface/transformers/tree/v2.6.0/examples"),p(Ct,"href","https://github.com/huggingface/transformers/tree/v2.5.1/examples"),p(Dt,"href","https://github.com/huggingface/transformers/tree/v2.4.0/examples"),p(Nt,"href","https://github.com/huggingface/transformers/tree/v2.3.0/examples"),p(Ot,"href","https://github.com/huggingface/transformers/tree/v2.2.0/examples"),p(jt,"href","https://github.com/huggingface/transformers/tree/v2.1.0/examples"),p(Ft,"href","https://github.com/huggingface/transformers/tree/v2.0.0/examples"),p(Rt,"href","https://github.com/huggingface/transformers/tree/v1.2.0/examples"),p(Ht,"href","https://github.com/huggingface/transformers/tree/v1.1.0/examples"),p(Mt,"href","https://github.com/huggingface/transformers/tree/v1.0.0/examples"),p(ee,"id","run-a-script"),p(ee,"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"),p(ee,"href","#run-a-script"),p(M,"class","relative group"),p(Se,"href","https://huggingface.co/docs/datasets/"),p(Se,"rel","nofollow"),p(Ue,"href","https://huggingface.co/docs/transformers/main_classes/trainer"),p(Ue,"rel","nofollow"),p(Ce,"href","https://huggingface.co/t5-small"),p(Ce,"rel","nofollow"),p(De,"href","https://huggingface.co/datasets/cnn_dailymail"),p(De,"rel","nofollow"),p(te,"id","distributed-training-and-mixed-precision"),p(te,"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"),p(te,"href","#distributed-training-and-mixed-precision"),p(G,"class","relative group"),p(je,"href","https://huggingface.co/docs/transformers/main_classes/trainer"),p(je,"rel","nofollow"),p(Me,"href","https://www.tensorflow.org/guide/distributed_training#mirroredstrategy"),p(Me,"rel","nofollow"),p(ie,"id","run-a-script-on-a-tpu"),p(ie,"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"),p(ie,"href","#run-a-script-on-a-tpu"),p(B,"class","relative group"),p(Be,"href","https://www.tensorflow.org/xla"),p(Be,"rel","nofollow"),p(Je,"href","https://github.com/pytorch/xla/blob/master/README.md"),p(Je,"rel","nofollow"),p(We,"href","https://www.tensorflow.org/guide/distributed_training#tpustrategy"),p(We,"rel","nofollow"),p(se,"id","run-a-script-with-accelerate"),p(se,"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"),p(se,"href","#run-a-script-with-accelerate"),p(J,"class","relative group"),p(Ve,"href","https://huggingface.co/docs/accelerate/index.html"),p(Ve,"rel","nofollow"),p(ne,"id","use-a-custom-dataset"),p(ne,"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"),p(ne,"href","#use-a-custom-dataset"),p(W,"class","relative group"),p(ue,"id","test-a-script"),p(ue,"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"),p(ue,"href","#test-a-script"),p(X,"class","relative group"),p(he,"id","resume-training-from-checkpoint"),p(he,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(he,"href","#resume-training-from-checkpoint"),p(Y,"class","relative group"),p(fe,"id","share-your-model"),p(fe,"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"),p(fe,"href","#share-your-model"),p(V,"class","relative group"),p(ut,"href","https://huggingface.co/models"),p(ut,"rel","nofollow")},m(e,n){t(document.head,q),u(e,ft,n),u(e,z,n),t(z,P),t(P,pr),v(ge,pr,null),t(z,ui),t(z,ur),t(ur,hi),u(e,Ca,n),u(e,b,n),t(b,mi),t(b,ct),t(ct,fi),t(b,ci),t(b,ye),t(ye,_i),t(b,di),t(b,we),t(we,vi),t(b,gi),t(b,Ee),t(Ee,yi),t(b,wi),u(e,Da,n),u(e,I,n),t(I,Ei),t(I,$e),t($e,$i),t(I,bi),t(I,be),t(be,xi),t(I,zi),u(e,Na,n),u(e,_t,n),t(_t,Ti),u(e,Oa,n),u(e,L,n),t(L,ki),t(L,xe),t(xe,Ai),t(L,Pi),t(L,ze),t(ze,qi),t(L,Ii),u(e,ja,n),u(e,S,n),t(S,Li),t(S,Te),t(Te,Si),t(S,Ui),t(S,ke),t(ke,Ci),t(S,Di),u(e,Fa,n),u(e,H,n),t(H,K),t(K,hr),v(Ae,hr,null),t(H,Ni),t(H,mr),t(mr,Oi),u(e,Ra,n),u(e,Q,n),t(Q,ji),t(Q,fr),t(fr,Fi),t(Q,Ri),u(e,Ha,n),v(Pe,e,n),u(e,Ma,n),u(e,dt,n),t(dt,Hi),u(e,Ga,n),u(e,Z,n),t(Z,cr),t(cr,Mi),t(Z,Gi),t(Z,f),t(f,_r),t(_r,vt),t(vt,Bi),t(f,Ji),t(f,dr),t(dr,gt),t(gt,Wi),t(f,Xi),t(f,vr),t(vr,yt),t(yt,Yi),t(f,Vi),t(f,gr),t(gr,wt),t(wt,Ki),t(f,Qi),t(f,yr),t(yr,Et),t(Et,Zi),t(f,es),t(f,wr),t(wr,$t),t($t,ts),t(f,rs),t(f,Er),t(Er,bt),t(bt,as),t(f,os),t(f,$r),t($r,xt),t(xt,is),t(f,ss),t(f,br),t(br,zt),t(zt,ls),t(f,ns),t(f,xr),t(xr,Tt),t(Tt,ps),t(f,us),t(f,zr),t(zr,kt),t(kt,hs),t(f,ms),t(f,Tr),t(Tr,At),t(At,fs),t(f,cs),t(f,kr),t(kr,Pt),t(Pt,_s),t(f,ds),t(f,Ar),t(Ar,qt),t(qt,vs),t(f,gs),t(f,Pr),t(Pr,It),t(It,ys),t(f,ws),t(f,qr),t(qr,Lt),t(Lt,Es),t(f,$s),t(f,Ir),t(Ir,St),t(St,bs),t(f,xs),t(f,Lr),t(Lr,Ut),t(Ut,zs),t(f,Ts),t(f,Sr),t(Sr,Ct),t(Ct,ks),t(f,As),t(f,Ur),t(Ur,Dt),t(Dt,Ps),t(f,qs),t(f,Cr),t(Cr,Nt),t(Nt,Is),t(f,Ls),t(f,Dr),t(Dr,Ot),t(Ot,Ss),t(f,Us),t(f,Nr),t(Nr,jt),t(jt,Cs),t(f,Ds),t(f,Or),t(Or,Ft),t(Ft,Ns),t(f,Os),t(f,jr),t(jr,Rt),t(Rt,js),t(f,Fs),t(f,Fr),t(Fr,Ht),t(Ht,Rs),t(f,Hs),t(f,Rr),t(Rr,Mt),t(Mt,Ms),u(e,Ba,n),u(e,Gt,n),t(Gt,Gs),u(e,Ja,n),v(qe,e,n),u(e,Wa,n),u(e,Bt,n),t(Bt,Bs),u(e,Xa,n),v(Ie,e,n),u(e,Ya,n),u(e,M,n),t(M,ee),t(ee,Hr),v(Le,Hr,null),t(M,Js),t(M,Mr),t(Mr,Ws),u(e,Va,n),u(e,E,n),t(E,Xs),t(E,Se),t(Se,Ys),t(E,Vs),t(E,Ue),t(Ue,Ks),t(E,Qs),t(E,Ce),t(Ce,Zs),t(E,el),t(E,De),t(De,tl),t(E,rl),t(E,Gr),t(Gr,al),t(E,ol),u(e,Ka,n),v(Ne,e,n),u(e,Qa,n),u(e,G,n),t(G,te),t(te,Br),v(Oe,Br,null),t(G,il),t(G,Jr),t(Jr,sl),u(e,Za,n),u(e,re,n),t(re,ll),t(re,je),t(je,nl),t(re,pl),u(e,eo,n),u(e,ae,n),t(ae,Fe),t(Fe,ul),t(Fe,Wr),t(Wr,hl),t(Fe,ml),t(ae,fl),t(ae,Re),t(Re,cl),t(Re,Xr),t(Xr,_l),t(Re,dl),u(e,to,n),v(He,e,n),u(e,ro,n),u(e,oe,n),t(oe,vl),t(oe,Me),t(Me,Yr),t(Yr,gl),t(oe,yl),u(e,ao,n),u(e,B,n),t(B,ie),t(ie,Vr),v(Ge,Vr,null),t(B,wl),t(B,Kr),t(Kr,El),u(e,oo,n),u(e,x,n),t(x,$l),t(x,Be),t(Be,bl),t(x,xl),t(x,Je),t(Je,zl),t(x,Tl),t(x,Qr),t(Qr,kl),t(x,Al),t(x,Zr),t(Zr,Pl),t(x,ql),u(e,io,n),u(e,U,n),t(U,Il),t(U,We),t(We,ea),t(ea,Ll),t(U,Sl),t(U,ta),t(ta,Ul),t(U,Cl),u(e,so,n),v(Xe,e,n),u(e,lo,n),u(e,J,n),t(J,se),t(se,ra),v(Ye,ra,null),t(J,Dl),t(J,aa),t(aa,Nl),u(e,no,n),u(e,le,n),t(le,Ol),t(le,Ve),t(Ve,jl),t(le,Fl),u(e,po,n),v(Ke,e,n),u(e,uo,n),u(e,T,n),t(T,Rl),t(T,oa),t(oa,Hl),t(T,Ml),t(T,ia),t(ia,Gl),t(T,Bl),t(T,sa),t(sa,Jl),t(T,Wl),u(e,ho,n),v(Qe,e,n),u(e,mo,n),u(e,Jt,n),t(Jt,Xl),u(e,fo,n),v(Ze,e,n),u(e,co,n),u(e,Wt,n),t(Wt,Yl),u(e,_o,n),v(et,e,n),u(e,vo,n),u(e,W,n),t(W,ne),t(ne,la),v(tt,la,null),t(W,Vl),t(W,na),t(na,Kl),u(e,go,n),u(e,Xt,n),t(Xt,Ql),u(e,yo,n),u(e,C,n),t(C,pe),t(pe,pa),t(pa,Zl),t(pe,en),t(pe,ua),t(ua,tn),t(pe,rn),t(C,an),t(C,Yt),t(Yt,ha),t(ha,on),t(Yt,sn),t(C,ln),t(C,Vt),t(Vt,ma),t(ma,nn),t(Vt,pn),u(e,wo,n),u(e,Kt,n),t(Kt,un),u(e,Eo,n),v(rt,e,n),u(e,$o,n),u(e,X,n),t(X,ue),t(ue,fa),v(at,fa,null),t(X,hn),t(X,ca),t(ca,mn),u(e,bo,n),u(e,Qt,n),t(Qt,fn),u(e,xo,n),u(e,D,n),t(D,_a),t(_a,da),t(da,cn),t(D,_n),t(D,va),t(va,ga),t(ga,dn),t(D,vn),t(D,ya),t(ya,wa),t(wa,gn),u(e,zo,n),v(ot,e,n),u(e,To,n),u(e,N,n),t(N,yn),t(N,Ea),t(Ea,wn),t(N,En),t(N,$a),t($a,$n),t(N,bn),u(e,ko,n),v(it,e,n),u(e,Ao,n),u(e,Y,n),t(Y,he),t(he,ba),v(st,ba,null),t(Y,xn),t(Y,xa),t(xa,zn),u(e,Po,n),u(e,Zt,n),t(Zt,Tn),u(e,qo,n),u(e,k,n),t(k,kn),t(k,za),t(za,An),t(k,Pn),t(k,Ta),t(Ta,qn),t(k,In),t(k,ka),t(ka,Ln),t(k,Sn),u(e,Io,n),v(lt,e,n),u(e,Lo,n),u(e,me,n),t(me,Un),t(me,Aa),t(Aa,Cn),t(me,Dn),u(e,So,n),v(nt,e,n),u(e,Uo,n),u(e,V,n),t(V,fe),t(fe,Pa),v(pt,Pa,null),t(V,Nn),t(V,qa),t(qa,On),u(e,Co,n),u(e,ce,n),t(ce,jn),t(ce,ut),t(ut,Fn),t(ce,Rn),u(e,Do,n),v(ht,e,n),u(e,No,n),u(e,O,n),t(O,Hn),t(O,Ia),t(Ia,Mn),t(O,Gn),t(O,La),t(La,Bn),t(O,Jn),u(e,Oo,n),u(e,_e,n),t(_e,Wn),t(_e,Sa),t(Sa,Xn),t(_e,Yn),u(e,jo,n),u(e,er,n),t(er,Vn),u(e,Fo,n),v(mt,e,n),Ro=!0},p:Gh,i(e){Ro||(g(ge.$$.fragment,e),g(Ae.$$.fragment,e),g(Pe.$$.fragment,e),g(qe.$$.fragment,e),g(Ie.$$.fragment,e),g(Le.$$.fragment,e),g(Ne.$$.fragment,e),g(Oe.$$.fragment,e),g(He.$$.fragment,e),g(Ge.$$.fragment,e),g(Xe.$$.fragment,e),g(Ye.$$.fragment,e),g(Ke.$$.fragment,e),g(Qe.$$.fragment,e),g(Ze.$$.fragment,e),g(et.$$.fragment,e),g(tt.$$.fragment,e),g(rt.$$.fragment,e),g(at.$$.fragment,e),g(ot.$$.fragment,e),g(it.$$.fragment,e),g(st.$$.fragment,e),g(lt.$$.fragment,e),g(nt.$$.fragment,e),g(pt.$$.fragment,e),g(ht.$$.fragment,e),g(mt.$$.fragment,e),Ro=!0)},o(e){y(ge.$$.fragment,e),y(Ae.$$.fragment,e),y(Pe.$$.fragment,e),y(qe.$$.fragment,e),y(Ie.$$.fragment,e),y(Le.$$.fragment,e),y(Ne.$$.fragment,e),y(Oe.$$.fragment,e),y(He.$$.fragment,e),y(Ge.$$.fragment,e),y(Xe.$$.fragment,e),y(Ye.$$.fragment,e),y(Ke.$$.fragment,e),y(Qe.$$.fragment,e),y(Ze.$$.fragment,e),y(et.$$.fragment,e),y(tt.$$.fragment,e),y(rt.$$.fragment,e),y(at.$$.fragment,e),y(ot.$$.fragment,e),y(it.$$.fragment,e),y(st.$$.fragment,e),y(lt.$$.fragment,e),y(nt.$$.fragment,e),y(pt.$$.fragment,e),y(ht.$$.fragment,e),y(mt.$$.fragment,e),Ro=!1},d(e){r(q),e&&r(ft),e&&r(z),w(ge),e&&r(Ca),e&&r(b),e&&r(Da),e&&r(I),e&&r(Na),e&&r(_t),e&&r(Oa),e&&r(L),e&&r(ja),e&&r(S),e&&r(Fa),e&&r(H),w(Ae),e&&r(Ra),e&&r(Q),e&&r(Ha),w(Pe,e),e&&r(Ma),e&&r(dt),e&&r(Ga),e&&r(Z),e&&r(Ba),e&&r(Gt),e&&r(Ja),w(qe,e),e&&r(Wa),e&&r(Bt),e&&r(Xa),w(Ie,e),e&&r(Ya),e&&r(M),w(Le),e&&r(Va),e&&r(E),e&&r(Ka),w(Ne,e),e&&r(Qa),e&&r(G),w(Oe),e&&r(Za),e&&r(re),e&&r(eo),e&&r(ae),e&&r(to),w(He,e),e&&r(ro),e&&r(oe),e&&r(ao),e&&r(B),w(Ge),e&&r(oo),e&&r(x),e&&r(io),e&&r(U),e&&r(so),w(Xe,e),e&&r(lo),e&&r(J),w(Ye),e&&r(no),e&&r(le),e&&r(po),w(Ke,e),e&&r(uo),e&&r(T),e&&r(ho),w(Qe,e),e&&r(mo),e&&r(Jt),e&&r(fo),w(Ze,e),e&&r(co),e&&r(Wt),e&&r(_o),w(et,e),e&&r(vo),e&&r(W),w(tt),e&&r(go),e&&r(Xt),e&&r(yo),e&&r(C),e&&r(wo),e&&r(Kt),e&&r(Eo),w(rt,e),e&&r($o),e&&r(X),w(at),e&&r(bo),e&&r(Qt),e&&r(xo),e&&r(D),e&&r(zo),w(ot,e),e&&r(To),e&&r(N),e&&r(ko),w(it,e),e&&r(Ao),e&&r(Y),w(st),e&&r(Po),e&&r(Zt),e&&r(qo),e&&r(k),e&&r(Io),w(lt,e),e&&r(Lo),e&&r(me),e&&r(So),w(nt,e),e&&r(Uo),e&&r(V),w(pt),e&&r(Co),e&&r(ce),e&&r(Do),w(ht,e),e&&r(No),e&&r(O),e&&r(Oo),e&&r(_e),e&&r(jo),e&&r(er),e&&r(Fo),w(mt,e)}}}const Jh={local:"train-with-a-script",sections:[{local:"setup",title:"Setup"},{local:"run-a-script",title:"Run a script"},{local:"distributed-training-and-mixed-precision",title:"Distributed training and mixed precision"},{local:"run-a-script-on-a-tpu",title:"Run a script on a TPU"},{local:"run-a-script-with-accelerate",title:"Run a script with \u{1F917} Accelerate"},{local:"use-a-custom-dataset",title:"Use a custom dataset"},{local:"test-a-script",title:"Test a script"},{local:"resume-training-from-checkpoint",title:"Resume training from checkpoint"},{local:"share-your-model",title:"Share your model"}],title:"Train with a script"};function Wh(pi,q,ft){let{fw:z}=q;return pi.$$set=P=>{"fw"in P&&ft(0,z=P.fw)},[z]}class Zh extends Fh{constructor(q){super();Rh(this,q,Wh,Bh,Hh,{fw:0})}}export{Zh as default,Jh as metadata};
