import{s as Ns,o as Fs,n as $e}from"../chunks/scheduler.9bc65507.js";import{S as Ss,i as zs,g as h,s as p,u as y,A as Ys,h as f,f as t,c as i,j as E,v as M,y as j,k as W,o as V,a as l,w as g,d as b,t as w,x as $,m as Is,n as Es}from"../chunks/index.78c82d43.js";import{T as ls}from"../chunks/Tip.87d55b76.js";import{Y as Hs}from"../chunks/Youtube.b19762b6.js";import{I as nt}from"../chunks/IconCopyLink.bedaa44d.js";import{C as Z}from"../chunks/CodeBlock.73e038be.js";import{D as Qs}from"../chunks/DocNotebookDropdown.31840a23.js";import{F as is,M as rt}from"../chunks/Markdown.1b9b4e1c.js";function qs(v){let a,c,s='<a href="../model_doc/bart">BART</a>, <a href="../model_doc/bigbird_pegasus">BigBird-Pegasus</a>, <a href="../model_doc/blenderbot">Blenderbot</a>, <a href="../model_doc/blenderbot-small">BlenderbotSmall</a>, <a href="../model_doc/encoder-decoder">Encoder decoder</a>, <a href="../model_doc/fsmt">FairSeq Machine-Translation</a>, <a href="../model_doc/gptsan-japanese">GPTSAN-japanese</a>, <a href="../model_doc/led">LED</a>, <a href="../model_doc/longt5">LongT5</a>, <a href="../model_doc/m2m_100">M2M100</a>, <a href="../model_doc/marian">Marian</a>, <a href="../model_doc/mbart">mBART</a>, <a href="../model_doc/mt5">MT5</a>, <a href="../model_doc/mvp">MVP</a>, <a href="../model_doc/nllb">NLLB</a>, <a href="../model_doc/nllb-moe">NLLB-MOE</a>, <a href="../model_doc/pegasus">Pegasus</a>, <a href="../model_doc/pegasus_x">PEGASUS-X</a>, <a href="../model_doc/plbart">PLBart</a>, <a href="../model_doc/prophetnet">ProphetNet</a>, <a href="../model_doc/switch_transformers">SwitchTransformers</a>, <a href="../model_doc/t5">T5</a>, <a href="../model_doc/umt5">UMT5</a>, <a href="../model_doc/xlm-prophetnet">XLM-ProphetNet</a>';return{c(){a=Is(`The task illustrated in this tutorial is supported by the following model architectures:

`),c=h("p"),c.innerHTML=s},l(m){a=Es(m,`The task illustrated in this tutorial is supported by the following model architectures:

`),c=f(m,"P",{"data-svelte-h":!0}),j(c)!=="svelte-2s8ce4"&&(c.innerHTML=s)},m(m,d){l(m,a,d),l(m,c,d)},p:$e,d(m){m&&(t(a),t(c))}}}function As(v){let a,c;return a=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRGNoZWNrcG9pbnQp",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)`,wrap:!1}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p:$e,i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function Ls(v){let a,c;return a=new rt({props:{$$slots:{default:[As]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function Ps(v){let a,c;return a=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvclNlcTJTZXElMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yU2VxMlNlcSh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtb2RlbCUzRGNoZWNrcG9pbnQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",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>)`,wrap:!1}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p:$e,i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function Ds(v){let a,c;return a=new rt({props:{$$slots:{default:[Ps]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function Ks(v){let a,c='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a>, take a look at the basic tutorial <a href="../training#train-with-pytorch-trainer">here</a>!';return{c(){a=h("p"),a.innerHTML=c},l(s){a=f(s,"P",{"data-svelte-h":!0}),j(a)!=="svelte-1ufp0ay"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:$e,d(s){s&&t(a)}}}function Os(v){let a,c,s,m='You’re ready to start training your model now! Load T5 with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a>:',d,k,H,J,G="At this point, only three steps remain:",R,B,N='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Seq2SeqTrainingArguments">Seq2SeqTrainingArguments</a>. The only required parameter is <code>output_dir</code> which specifies where to save your model. You’ll push this model to the Hub by setting <code>push_to_hub=True</code> (you need to be signed in to Hugging Face to upload your model). At the end of each epoch, the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer">Trainer</a> will evaluate the SacreBLEU metric and save the training checkpoint.</li> <li>Pass the training arguments to <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Seq2SeqTrainer">Seq2SeqTrainer</a> along with the model, dataset, tokenizer, data collator, and <code>compute_metrics</code> function.</li> <li>Call <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',C,U,x,o,_='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.34.0/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',Q,S,I;return a=new ls({props:{$$slots:{default:[Ks]},$$scope:{ctx:v}}}),k=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFNlcTJTZXFUcmFpbmVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQp",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)`,wrap:!1}}),U=new Z({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIybXlfYXdlc29tZV9vcHVzX2Jvb2tzX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbHVhdGlvbl9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rfd2l0aF9nZW5lcmF0ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwU2VxMlNlcVRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRva2VuaXplZF9ib29rcyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX2Jvb2tzJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwY29tcHV0ZV9tZXRyaWNzJTNEY29tcHV0ZV9tZXRyaWNzJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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_opus_books_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">2</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_books[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_books[<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()`,wrap:!1}}),S=new Z({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){y(a.$$.fragment),c=p(),s=h("p"),s.innerHTML=m,d=p(),y(k.$$.fragment),H=p(),J=h("p"),J.textContent=G,R=p(),B=h("ol"),B.innerHTML=N,C=p(),y(U.$$.fragment),x=p(),o=h("p"),o.innerHTML=_,Q=p(),y(S.$$.fragment)},l(u){M(a.$$.fragment,u),c=i(u),s=f(u,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1h2b6hn"&&(s.innerHTML=m),d=i(u),M(k.$$.fragment,u),H=i(u),J=f(u,"P",{"data-svelte-h":!0}),j(J)!=="svelte-l42k0i"&&(J.textContent=G),R=i(u),B=f(u,"OL",{"data-svelte-h":!0}),j(B)!=="svelte-aresqc"&&(B.innerHTML=N),C=i(u),M(U.$$.fragment,u),x=i(u),o=f(u,"P",{"data-svelte-h":!0}),j(o)!=="svelte-cv8z08"&&(o.innerHTML=_),Q=i(u),M(S.$$.fragment,u)},m(u,X){g(a,u,X),l(u,c,X),l(u,s,X),l(u,d,X),g(k,u,X),l(u,H,X),l(u,J,X),l(u,R,X),l(u,B,X),l(u,C,X),g(U,u,X),l(u,x,X),l(u,o,X),l(u,Q,X),g(S,u,X),I=!0},p(u,X){const F={};X&2&&(F.$$scope={dirty:X,ctx:u}),a.$set(F)},i(u){I||(b(a.$$.fragment,u),b(k.$$.fragment,u),b(U.$$.fragment,u),b(S.$$.fragment,u),I=!0)},o(u){w(a.$$.fragment,u),w(k.$$.fragment,u),w(U.$$.fragment,u),w(S.$$.fragment,u),I=!1},d(u){u&&(t(c),t(s),t(d),t(H),t(J),t(R),t(B),t(C),t(x),t(o),t(Q)),$(a,u),$(k,u),$(U,u),$(S,u)}}}function ea(v){let a,c;return a=new rt({props:{$$slots:{default:[Os]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function ta(v){let a,c='If you aren’t familiar with finetuning a model with Keras, take a look at the basic tutorial <a href="../training#train-a-tensorflow-model-with-keras">here</a>!';return{c(){a=h("p"),a.innerHTML=c},l(s){a=f(s,"P",{"data-svelte-h":!0}),j(a)!=="svelte-1rd4nl8"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:$e,d(s){s&&t(a)}}}function sa(v){let a,c,s,m,d,k='Then you can load T5 with <a href="/docs/transformers/v4.34.0/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a>:',H,J,G,R,B='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.34.0/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',N,C,U,x,o='Configure the model for training with <a href="https://keras.io/api/models/model_training_apis/#compile-method" rel="nofollow"><code>compile</code></a>. Note that Transformers models all have a default task-relevant loss function, so you don’t need to specify one unless you want to:',_,Q,S,I,u='The last two things to setup before you start training is to compute the SacreBLEU metric from the predictions, and provide a way to push your model to the Hub. Both are done by using <a href="../main_classes/keras_callbacks">Keras callbacks</a>.',X,F,ot='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',te,Y,se,q,pt='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.34.0/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',ae,A,le,L,it="Then bundle your callbacks together:",ne,P,re,z,O='Finally, you’re ready to start training your model! Call <a href="https://keras.io/api/models/model_training_apis/#fit-method" rel="nofollow"><code>fit</code></a> with your training and validation datasets, the number of epochs, and your callbacks to finetune the model:',ee,D,he,K,ct="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",oe;return a=new ls({props:{$$slots:{default:[ta]},$$scope:{ctx:v}}}),s=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEFkYW1XZWlnaHREZWNheSUwQSUwQW9wdGltaXplciUyMCUzRCUyMEFkYW1XZWlnaHREZWNheShsZWFybmluZ19yYXRlJTNEMmUtNSUyQyUyMHdlaWdodF9kZWNheV9yYXRlJTNEMC4wMSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> 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>)`,wrap:!1}}),J=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCk=",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)`,wrap:!1}}),C=new Z({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwbW9kZWwucHJlcGFyZV90Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMHRva2VuaXplZF9ib29rcyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl90ZXN0X3NldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjB0b2tlbml6ZWRfYm9va3MlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = model.prepare_tf_dataset(
<span class="hljs-meta">... </span>    tokenized_books[<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_books[<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>)`,wrap:!1}}),Q=new Z({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplciklMjAlMjAlMjMlMjBObyUyMGxvc3MlMjBhcmd1bWVudCE=",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)  <span class="hljs-comment"># No loss argument!</span>`,wrap:!1}}),Y=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTBBJTBBbWV0cmljX2NhbGxiYWNrJTIwJTNEJTIwS2VyYXNNZXRyaWNDYWxsYmFjayhtZXRyaWNfZm4lM0Rjb21wdXRlX21ldHJpY3MlMkMlMjBldmFsX2RhdGFzZXQlM0R0Zl92YWxpZGF0aW9uX3NldCk=",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)`,wrap:!1}}),A=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBQdXNoVG9IdWJDYWxsYmFjayUwQSUwQXB1c2hfdG9faHViX2NhbGxiYWNrJTIwJTNEJTIwUHVzaFRvSHViQ2FsbGJhY2soJTBBJTIwJTIwJTIwJTIwb3V0cHV0X2RpciUzRCUyMm15X2F3ZXNvbWVfb3B1c19ib29rc19tb2RlbCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSk=",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_opus_books_model&quot;</span>,
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>)`,wrap:!1}}),P=new Z({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),D=new Z({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl90ZXN0X3NldCUyQyUyMGVwb2NocyUzRDMlMkMlMjBjYWxsYmFja3MlM0RjYWxsYmFja3Mp",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)',wrap:!1}}),{c(){y(a.$$.fragment),c=Is(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),y(s.$$.fragment),m=p(),d=h("p"),d.innerHTML=k,H=p(),y(J.$$.fragment),G=p(),R=h("p"),R.innerHTML=B,N=p(),y(C.$$.fragment),U=p(),x=h("p"),x.innerHTML=o,_=p(),y(Q.$$.fragment),S=p(),I=h("p"),I.innerHTML=u,X=p(),F=h("p"),F.innerHTML=ot,te=p(),y(Y.$$.fragment),se=p(),q=h("p"),q.innerHTML=pt,ae=p(),y(A.$$.fragment),le=p(),L=h("p"),L.textContent=it,ne=p(),y(P.$$.fragment),re=p(),z=h("p"),z.innerHTML=O,ee=p(),y(D.$$.fragment),he=p(),K=h("p"),K.textContent=ct},l(n){M(a.$$.fragment,n),c=Es(n,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),M(s.$$.fragment,n),m=i(n),d=f(n,"P",{"data-svelte-h":!0}),j(d)!=="svelte-d8bckx"&&(d.innerHTML=k),H=i(n),M(J.$$.fragment,n),G=i(n),R=f(n,"P",{"data-svelte-h":!0}),j(R)!=="svelte-qmwuyd"&&(R.innerHTML=B),N=i(n),M(C.$$.fragment,n),U=i(n),x=f(n,"P",{"data-svelte-h":!0}),j(x)!=="svelte-17cxx5e"&&(x.innerHTML=o),_=i(n),M(Q.$$.fragment,n),S=i(n),I=f(n,"P",{"data-svelte-h":!0}),j(I)!=="svelte-13cue08"&&(I.innerHTML=u),X=i(n),F=f(n,"P",{"data-svelte-h":!0}),j(F)!=="svelte-6vs5z9"&&(F.innerHTML=ot),te=i(n),M(Y.$$.fragment,n),se=i(n),q=f(n,"P",{"data-svelte-h":!0}),j(q)!=="svelte-b2vwd"&&(q.innerHTML=pt),ae=i(n),M(A.$$.fragment,n),le=i(n),L=f(n,"P",{"data-svelte-h":!0}),j(L)!=="svelte-1lw9xm8"&&(L.textContent=it),ne=i(n),M(P.$$.fragment,n),re=i(n),z=f(n,"P",{"data-svelte-h":!0}),j(z)!=="svelte-1hrpv1v"&&(z.innerHTML=O),ee=i(n),M(D.$$.fragment,n),he=i(n),K=f(n,"P",{"data-svelte-h":!0}),j(K)!=="svelte-2s71om"&&(K.textContent=ct)},m(n,T){g(a,n,T),l(n,c,T),g(s,n,T),l(n,m,T),l(n,d,T),l(n,H,T),g(J,n,T),l(n,G,T),l(n,R,T),l(n,N,T),g(C,n,T),l(n,U,T),l(n,x,T),l(n,_,T),g(Q,n,T),l(n,S,T),l(n,I,T),l(n,X,T),l(n,F,T),l(n,te,T),g(Y,n,T),l(n,se,T),l(n,q,T),l(n,ae,T),g(A,n,T),l(n,le,T),l(n,L,T),l(n,ne,T),g(P,n,T),l(n,re,T),l(n,z,T),l(n,ee,T),g(D,n,T),l(n,he,T),l(n,K,T),oe=!0},p(n,T){const je={};T&2&&(je.$$scope={dirty:T,ctx:n}),a.$set(je)},i(n){oe||(b(a.$$.fragment,n),b(s.$$.fragment,n),b(J.$$.fragment,n),b(C.$$.fragment,n),b(Q.$$.fragment,n),b(Y.$$.fragment,n),b(A.$$.fragment,n),b(P.$$.fragment,n),b(D.$$.fragment,n),oe=!0)},o(n){w(a.$$.fragment,n),w(s.$$.fragment,n),w(J.$$.fragment,n),w(C.$$.fragment,n),w(Q.$$.fragment,n),w(Y.$$.fragment,n),w(A.$$.fragment,n),w(P.$$.fragment,n),w(D.$$.fragment,n),oe=!1},d(n){n&&(t(c),t(m),t(d),t(H),t(G),t(R),t(N),t(U),t(x),t(_),t(S),t(I),t(X),t(F),t(te),t(se),t(q),t(ae),t(le),t(L),t(ne),t(re),t(z),t(ee),t(he),t(K)),$(a,n),$(s,n),$(J,n),$(C,n),$(Q,n),$(Y,n),$(A,n),$(P,n),$(D,n)}}}function aa(v){let a,c;return a=new rt({props:{$$slots:{default:[sa]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function la(v){let a,c=`For a more in-depth example of how to finetune a model for translation, take a look at the corresponding
<a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation.ipynb" rel="nofollow">PyTorch notebook</a>
or <a href="https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation-tf.ipynb" rel="nofollow">TensorFlow notebook</a>.`;return{c(){a=h("p"),a.innerHTML=c},l(s){a=f(s,"P",{"data-svelte-h":!0}),j(a)!=="svelte-ikyjb6"&&(a.innerHTML=c)},m(s,m){l(s,a,m)},p:$e,d(s){s&&t(a)}}}function na(v){let a,c="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",s,m,d,k,H='Use the <a href="/docs/transformers/v4.34.0/en/main_classes/text_generation#transformers.GenerationMixin.generate">generate()</a> method to create the translation. For more details about the different text generation strategies and parameters for controlling generation, check out the <a href="../main_classes/text_generation">Text Generation</a> API.',J,G,R,B,N="Decode the generated token ids back into text:",C,U,x;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKS5pbnB1dF9pZHM=",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;my_awesome_opus_books_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`,wrap:!1}}),G=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENDAlMkMlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTIwdG9wX2slM0QzMCUyQyUyMHRvcF9wJTNEMC45NSk=",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;my_awesome_opus_books_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">40</span>, do_sample=<span class="hljs-literal">True</span>, top_k=<span class="hljs-number">30</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),U=new Z({props:{code:"dG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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;Les lignées partagent des ressources avec des bactéries enfixant l&#x27;</span>azote.<span class="hljs-string">&#x27;</span>`,wrap:!1}}),{c(){a=h("p"),a.innerHTML=c,s=p(),y(m.$$.fragment),d=p(),k=h("p"),k.innerHTML=H,J=p(),y(G.$$.fragment),R=p(),B=h("p"),B.textContent=N,C=p(),y(U.$$.fragment)},l(o){a=f(o,"P",{"data-svelte-h":!0}),j(a)!=="svelte-1c2y1ia"&&(a.innerHTML=c),s=i(o),M(m.$$.fragment,o),d=i(o),k=f(o,"P",{"data-svelte-h":!0}),j(k)!=="svelte-1bedpus"&&(k.innerHTML=H),J=i(o),M(G.$$.fragment,o),R=i(o),B=f(o,"P",{"data-svelte-h":!0}),j(B)!=="svelte-1918fu9"&&(B.textContent=N),C=i(o),M(U.$$.fragment,o)},m(o,_){l(o,a,_),l(o,s,_),g(m,o,_),l(o,d,_),l(o,k,_),l(o,J,_),g(G,o,_),l(o,R,_),l(o,B,_),l(o,C,_),g(U,o,_),x=!0},p:$e,i(o){x||(b(m.$$.fragment,o),b(G.$$.fragment,o),b(U.$$.fragment,o),x=!0)},o(o){w(m.$$.fragment,o),w(G.$$.fragment,o),w(U.$$.fragment,o),x=!1},d(o){o&&(t(a),t(s),t(d),t(k),t(J),t(R),t(B),t(C)),$(m,o),$(G,o),$(U,o)}}}function ra(v){let a,c;return a=new rt({props:{$$slots:{default:[na]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function oa(v){let a,c="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",s,m,d,k,H='Use the <a href="/docs/transformers/v4.34.0/en/main_classes/text_generation#transformers.TFGenerationMixin.generate">generate()</a> method to create the translation. For more details about the different text generation strategies and parameters for controlling generation, check out the <a href="../main_classes/text_generation">Text Generation</a> API.',J,G,R,B,N="Decode the generated token ids back into text:",C,U,x;return m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKS5pbnB1dF9pZHM=",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;my_awesome_opus_books_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`,wrap:!1}}),G=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIybXlfYXdlc29tZV9vcHVzX2Jvb2tzX21vZGVsJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZShpbnB1dHMlMkMlMjBtYXhfbmV3X3Rva2VucyUzRDQwJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRvcF9rJTNEMzAlMkMlMjB0b3BfcCUzRDAuOTUp",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;my_awesome_opus_books_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(inputs, max_new_tokens=<span class="hljs-number">40</span>, do_sample=<span class="hljs-literal">True</span>, top_k=<span class="hljs-number">30</span>, top_p=<span class="hljs-number">0.95</span>)`,wrap:!1}}),U=new Z({props:{code:"dG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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;Les lugumes partagent les ressources avec des bactéries fixatrices d&#x27;</span>azote.<span class="hljs-string">&#x27;</span>`,wrap:!1}}),{c(){a=h("p"),a.innerHTML=c,s=p(),y(m.$$.fragment),d=p(),k=h("p"),k.innerHTML=H,J=p(),y(G.$$.fragment),R=p(),B=h("p"),B.textContent=N,C=p(),y(U.$$.fragment)},l(o){a=f(o,"P",{"data-svelte-h":!0}),j(a)!=="svelte-hw2mu6"&&(a.innerHTML=c),s=i(o),M(m.$$.fragment,o),d=i(o),k=f(o,"P",{"data-svelte-h":!0}),j(k)!=="svelte-d60kj6"&&(k.innerHTML=H),J=i(o),M(G.$$.fragment,o),R=i(o),B=f(o,"P",{"data-svelte-h":!0}),j(B)!=="svelte-1918fu9"&&(B.textContent=N),C=i(o),M(U.$$.fragment,o)},m(o,_){l(o,a,_),l(o,s,_),g(m,o,_),l(o,d,_),l(o,k,_),l(o,J,_),g(G,o,_),l(o,R,_),l(o,B,_),l(o,C,_),g(U,o,_),x=!0},p:$e,i(o){x||(b(m.$$.fragment,o),b(G.$$.fragment,o),b(U.$$.fragment,o),x=!0)},o(o){w(m.$$.fragment,o),w(G.$$.fragment,o),w(U.$$.fragment,o),x=!1},d(o){o&&(t(a),t(s),t(d),t(k),t(J),t(R),t(B),t(C)),$(m,o),$(G,o),$(U,o)}}}function pa(v){let a,c;return a=new rt({props:{$$slots:{default:[oa]},$$scope:{ctx:v}}}),{c(){y(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,m){g(a,s,m),c=!0},p(s,m){const d={};m&2&&(d.$$scope={dirty:m,ctx:s}),a.$set(d)},i(s){c||(b(a.$$.fragment,s),c=!0)},o(s){w(a.$$.fragment,s),c=!1},d(s){$(a,s)}}}function ia(v){let a,c,s,m,d,k,H,J,G,R,B="Translation",N,C,U,x,o,_,Q="Translation converts a sequence of text from one language to another. It is one of several tasks you can formulate as a sequence-to-sequence problem, a powerful framework for returning some output from an input, like translation or summarization. Translation systems are commonly used for translation between different language texts, but it can also be used for speech or some combination in between like text-to-speech or speech-to-text.",S,I,u="This guide will show you how to:",X,F,ot='<li>Finetune <a href="https://huggingface.co/t5-small" rel="nofollow">T5</a> on the English-French subset of the <a href="https://huggingface.co/datasets/opus_books" rel="nofollow">OPUS Books</a> dataset to translate English text to French.</li> <li>Use your finetuned model for inference.</li>',te,Y,se,q,pt="Before you begin, make sure you have all the necessary libraries installed:",ae,A,le,L,it="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:",ne,P,re,z,O,ee,D,he,K,ct="Load OPUS Books dataset",oe,n,T='Start by loading the English-French subset of the <a href="https://huggingface.co/datasets/opus_books" rel="nofollow">OPUS Books</a> dataset from the 🤗 Datasets library:',je,Te,bt,_e,cs='Split the dataset into a train and test set with the <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',wt,ke,$t,Je,ms="Then take a look at an example:",jt,Ue,Tt,ve,hs="<code>translation</code>: an English and French translation of the text.",_t,pe,fe,mt,Ze,ns,tt,fs="Preprocess",kt,Ce,Jt,xe,us="The next step is to load a T5 tokenizer to process the English-French language pairs:",Ut,Re,vt,Be,ds="The preprocessing function you want to create needs to:",Zt,Xe,ys="<li>Prefix the input with a prompt so T5 knows this is a translation task. Some models capable of multiple NLP tasks require prompting for specific tasks.</li> <li>Tokenize the input (English) and target (French) separately because you can’t tokenize French text with a tokenizer pretrained on an English vocabulary.</li> <li>Truncate sequences to be no longer than the maximum length set by the <code>max_length</code> parameter.</li>",Ct,Ge,xt,We,Ms='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.14.5/en/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">map</a> method. You can speed up the <code>map</code> function by setting <code>batched=True</code> to process multiple elements of the dataset at once:',Rt,Ve,Bt,He,gs='Now create a batch of examples using <a href="/docs/transformers/v4.34.0/en/main_classes/data_collator#transformers.DataCollatorForSeq2Seq">DataCollatorForSeq2Seq</a>. It’s more efficient to <em>dynamically pad</em> the sentences to the longest length in a batch during collation, instead of padding the whole dataset to the maximum length.',Xt,ue,Gt,ie,de,ht,Ie,rs,st,bs="Evaluate",Wt,Ee,ws='Including a metric during training is often helpful for evaluating your model’s performance. You can quickly load a evaluation method with the 🤗 <a href="https://huggingface.co/docs/evaluate/index" rel="nofollow">Evaluate</a> library. For this task, load the <a href="https://huggingface.co/spaces/evaluate-metric/sacrebleu" rel="nofollow">SacreBLEU</a> metric (see the 🤗 Evaluate <a href="https://huggingface.co/docs/evaluate/a_quick_tour" rel="nofollow">quick tour</a> to learn more about how to load and compute a metric):',Vt,Ne,Ht,Fe,$s='Then create a function that passes your predictions and labels to <a href="https://huggingface.co/docs/evaluate/v0.4.0/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> to calculate the SacreBLEU score:',It,Se,Et,ze,js="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",Nt,ce,ye,ft,Ye,os,at,Ts="Train",Ft,Me,St,ge,zt,me,be,ut,Qe,ps,lt,_s="Inference",Yt,qe,ks="Great, now that you’ve finetuned a model, you can use it for inference!",Qt,Ae,Js="Come up with some text you’d like to translate to another language. For T5, you need to prefix your input depending on the task you’re working on. For translation from English to French, you should prefix your input as shown below:",qt,Le,At,Pe,Us='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.34.0/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for translation with your model, and pass your text to it:',Lt,De,Pt,Ke,vs="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",Dt,we,Kt,dt,Ot;return J=new nt({}),C=new Qs({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/translation.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/translation.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/translation.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/translation.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/translation.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/translation.ipynb"}]}}),x=new Hs({props:{id:"1JvfrvZgi6c"}}),Y=new ls({props:{$$slots:{default:[qs]},$$scope:{ctx:v}}}),A=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBzYWNyZWJsZXU=",highlighted:"pip install transformers datasets evaluate sacrebleu",wrap:!1}}),P=new Z({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",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()`,wrap:!1}}),D=new nt({}),Te=new Z({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBYm9va3MlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIyb3B1c19ib29rcyUyMiUyQyUyMCUyMmVuLWZyJTIyKQ==",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>books = load_dataset(<span class="hljs-string">&quot;opus_books&quot;</span>, <span class="hljs-string">&quot;en-fr&quot;</span>)`,wrap:!1}}),ke=new Z({props:{code:"Ym9va3MlMjAlM0QlMjBib29rcyU1QiUyMnRyYWluJTIyJTVELnRyYWluX3Rlc3Rfc3BsaXQodGVzdF9zaXplJTNEMC4yKQ==",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>books = books[<span class="hljs-string">&quot;train&quot;</span>].train_test_split(test_size=<span class="hljs-number">0.2</span>)',wrap:!1}}),Ue=new Z({props:{code:"Ym9va3MlNUIlMjJ0cmFpbiUyMiU1RCU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>books[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-string">&#x27;90560&#x27;</span>,
 <span class="hljs-string">&#x27;translation&#x27;</span>: {<span class="hljs-string">&#x27;en&#x27;</span>: <span class="hljs-string">&#x27;But this lofty plateau measured only a few fathoms, and soon we reentered Our Element.&#x27;</span>,
  <span class="hljs-string">&#x27;fr&#x27;</span>: <span class="hljs-string">&#x27;Mais ce plateau élevé ne mesurait que quelques toises, et bientôt nous fûmes rentrés dans notre élément.&#x27;</span>}}`,wrap:!1}}),Ze=new nt({}),Ce=new Hs({props:{id:"XAR8jnZZuUs"}}),Re=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIydDUtc21hbGwlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KQ==",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)`,wrap:!1}}),Ge=new Z({props:{code:"c291cmNlX2xhbmclMjAlM0QlMjAlMjJlbiUyMiUwQXRhcmdldF9sYW5nJTIwJTNEJTIwJTIyZnIlMjIlMEFwcmVmaXglMjAlM0QlMjAlMjJ0cmFuc2xhdGUlMjBFbmdsaXNoJTIwdG8lMjBGcmVuY2glM0ElMjAlMjIlMEElMEElMEFkZWYlMjBwcmVwcm9jZXNzX2Z1bmN0aW9uKGV4YW1wbGVzKSUzQSUwQSUyMCUyMCUyMCUyMGlucHV0cyUyMCUzRCUyMCU1QnByZWZpeCUyMCUyQiUyMGV4YW1wbGUlNUJzb3VyY2VfbGFuZyU1RCUyMGZvciUyMGV4YW1wbGUlMjBpbiUyMGV4YW1wbGVzJTVCJTIydHJhbnNsYXRpb24lMjIlNUQlNUQlMEElMjAlMjAlMjAlMjB0YXJnZXRzJTIwJTNEJTIwJTVCZXhhbXBsZSU1QnRhcmdldF9sYW5nJTVEJTIwZm9yJTIwZXhhbXBsZSUyMGluJTIwZXhhbXBsZXMlNUIlMjJ0cmFuc2xhdGlvbiUyMiU1RCU1RCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihpbnB1dHMlMkMlMjB0ZXh0X3RhcmdldCUzRHRhcmdldHMlMkMlMjBtYXhfbGVuZ3RoJTNEMTI4JTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbW9kZWxfaW5wdXRz",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>source_lang = <span class="hljs-string">&quot;en&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>target_lang = <span class="hljs-string">&quot;fr&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prefix = <span class="hljs-string">&quot;translate English to French: &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 + example[source_lang] <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;translation&quot;</span>]]
<span class="hljs-meta">... </span>    targets = [example[target_lang] <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> examples[<span class="hljs-string">&quot;translation&quot;</span>]]
<span class="hljs-meta">... </span>    model_inputs = tokenizer(inputs, text_target=targets, max_length=<span class="hljs-number">128</span>, truncation=<span class="hljs-literal">True</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> model_inputs`,wrap:!1}}),Ve=new Z({props:{code:"dG9rZW5pemVkX2Jvb2tzJTIwJTNEJTIwYm9va3MubWFwKHByZXByb2Nlc3NfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSk=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_books = books.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)',wrap:!1}}),ue=new is({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ds],pytorch:[Ls]},$$scope:{ctx:v}}}),Ie=new nt({}),Ne=new Z({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMnNhY3JlYmxldSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;sacrebleu&quot;</span>)`,wrap:!1}}),Se=new Z({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwcG9zdHByb2Nlc3NfdGV4dChwcmVkcyUyQyUyMGxhYmVscyklM0ElMEElMjAlMjAlMjAlMjBwcmVkcyUyMCUzRCUyMCU1QnByZWQuc3RyaXAoKSUyMGZvciUyMHByZWQlMjBpbiUyMHByZWRzJTVEJTBBJTIwJTIwJTIwJTIwbGFiZWxzJTIwJTNEJTIwJTVCJTVCbGFiZWwuc3RyaXAoKSU1RCUyMGZvciUyMGxhYmVsJTIwaW4lMjBsYWJlbHMlNUQlMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBwcmVkcyUyQyUyMGxhYmVscyUwQSUwQSUwQWRlZiUyMGNvbXB1dGVfbWV0cmljcyhldmFsX3ByZWRzKSUzQSUwQSUyMCUyMCUyMCUyMHByZWRzJTJDJTIwbGFiZWxzJTIwJTNEJTIwZXZhbF9wcmVkcyUwQSUyMCUyMCUyMCUyMGlmJTIwaXNpbnN0YW5jZShwcmVkcyUyQyUyMHR1cGxlKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByZWRzJTIwJTNEJTIwcHJlZHMlNUIwJTVEJTBBJTIwJTIwJTIwJTIwZGVjb2RlZF9wcmVkcyUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUocHJlZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBsYWJlbHMlMjAlM0QlMjBucC53aGVyZShsYWJlbHMlMjAhJTNEJTIwLTEwMCUyQyUyMGxhYmVscyUyQyUyMHRva2VuaXplci5wYWRfdG9rZW5faWQpJTBBJTIwJTIwJTIwJTIwZGVjb2RlZF9sYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGxhYmVscyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSUwQSUwQSUyMCUyMCUyMCUyMGRlY29kZWRfcHJlZHMlMkMlMjBkZWNvZGVkX2xhYmVscyUyMCUzRCUyMHBvc3Rwcm9jZXNzX3RleHQoZGVjb2RlZF9wcmVkcyUyQyUyMGRlY29kZWRfbGFiZWxzKSUwQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMG1ldHJpYy5jb21wdXRlKHByZWRpY3Rpb25zJTNEZGVjb2RlZF9wcmVkcyUyQyUyMHJlZmVyZW5jZXMlM0RkZWNvZGVkX2xhYmVscyklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjAlN0IlMjJibGV1JTIyJTNBJTIwcmVzdWx0JTVCJTIyc2NvcmUlMjIlNUQlN0QlMEElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9uX2xlbnMlMjAlM0QlMjAlNUJucC5jb3VudF9ub256ZXJvKHByZWQlMjAhJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCklMjBmb3IlMjBwcmVkJTIwaW4lMjBwcmVkcyU1RCUwQSUyMCUyMCUyMCUyMHJlc3VsdCU1QiUyMmdlbl9sZW4lMjIlNUQlMjAlM0QlMjBucC5tZWFuKHByZWRpY3Rpb25fbGVucyklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjAlN0JrJTNBJTIwcm91bmQodiUyQyUyMDQpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMHJlc3VsdC5pdGVtcygpJTdEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwcmVzdWx0",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_">postprocess_text</span>(<span class="hljs-params">preds, labels</span>):
<span class="hljs-meta">... </span>    preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
<span class="hljs-meta">... </span>    labels = [[label.strip()] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]

<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> preds, labels


<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_preds</span>):
<span class="hljs-meta">... </span>    preds, labels = eval_preds
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(preds, <span class="hljs-built_in">tuple</span>):
<span class="hljs-meta">... </span>        preds = preds[<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>    decoded_preds = tokenizer.batch_decode(preds, 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>    decoded_preds, decoded_labels = postprocess_text(decoded_preds, decoded_labels)

<span class="hljs-meta">... </span>    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
<span class="hljs-meta">... </span>    result = {<span class="hljs-string">&quot;bleu&quot;</span>: result[<span class="hljs-string">&quot;score&quot;</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> preds]
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;gen_len&quot;</span>] = np.mean(prediction_lens)
<span class="hljs-meta">... </span>    result = {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()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> result`,wrap:!1}}),Ye=new nt({}),Me=new is({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[aa],pytorch:[ea]},$$scope:{ctx:v}}}),ge=new ls({props:{$$slots:{default:[la]},$$scope:{ctx:v}}}),Qe=new nt({}),Le=new Z({props:{code:"dGV4dCUyMCUzRCUyMCUyMnRyYW5zbGF0ZSUyMEVuZ2xpc2glMjB0byUyMEZyZW5jaCUzQSUyMExlZ3VtZXMlMjBzaGFyZSUyMHJlc291cmNlcyUyMHdpdGglMjBuaXRyb2dlbi1maXhpbmclMjBiYWN0ZXJpYS4lMjI=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>text = <span class="hljs-string">&quot;translate English to French: Legumes share resources with nitrogen-fixing bacteria.&quot;</span>',wrap:!1}}),De=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdHJhbnNsYXRvciUyMCUzRCUyMHBpcGVsaW5lKCUyMnRyYW5zbGF0aW9uJTIyJTJDJTIwbW9kZWwlM0QlMjJteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBdHJhbnNsYXRvcih0ZXh0KQ==",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>translator = pipeline(<span class="hljs-string">&quot;translation&quot;</span>, model=<span class="hljs-string">&quot;my_awesome_opus_books_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>translator(text)
[{<span class="hljs-string">&#x27;translation_text&#x27;</span>: <span class="hljs-string">&#x27;Legumes partagent des ressources avec des bactéries azotantes.&#x27;</span>}]`,wrap:!1}}),we=new is({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[pa],pytorch:[ra]},$$scope:{ctx:v}}}),{c(){a=h("meta"),c=p(),s=h("p"),m=p(),d=h("h1"),k=h("a"),H=h("span"),y(J.$$.fragment),G=p(),R=h("span"),R.textContent=B,N=p(),y(C.$$.fragment),U=p(),y(x.$$.fragment),o=p(),_=h("p"),_.textContent=Q,S=p(),I=h("p"),I.textContent=u,X=p(),F=h("ol"),F.innerHTML=ot,te=p(),y(Y.$$.fragment),se=p(),q=h("p"),q.textContent=pt,ae=p(),y(A.$$.fragment),le=p(),L=h("p"),L.textContent=it,ne=p(),y(P.$$.fragment),re=p(),z=h("h2"),O=h("a"),ee=h("span"),y(D.$$.fragment),he=p(),K=h("span"),K.textContent=ct,oe=p(),n=h("p"),n.innerHTML=T,je=p(),y(Te.$$.fragment),bt=p(),_e=h("p"),_e.innerHTML=cs,wt=p(),y(ke.$$.fragment),$t=p(),Je=h("p"),Je.textContent=ms,jt=p(),y(Ue.$$.fragment),Tt=p(),ve=h("p"),ve.innerHTML=hs,_t=p(),pe=h("h2"),fe=h("a"),mt=h("span"),y(Ze.$$.fragment),ns=p(),tt=h("span"),tt.textContent=fs,kt=p(),y(Ce.$$.fragment),Jt=p(),xe=h("p"),xe.textContent=us,Ut=p(),y(Re.$$.fragment),vt=p(),Be=h("p"),Be.textContent=ds,Zt=p(),Xe=h("ol"),Xe.innerHTML=ys,Ct=p(),y(Ge.$$.fragment),xt=p(),We=h("p"),We.innerHTML=Ms,Rt=p(),y(Ve.$$.fragment),Bt=p(),He=h("p"),He.innerHTML=gs,Xt=p(),y(ue.$$.fragment),Gt=p(),ie=h("h2"),de=h("a"),ht=h("span"),y(Ie.$$.fragment),rs=p(),st=h("span"),st.textContent=bs,Wt=p(),Ee=h("p"),Ee.innerHTML=ws,Vt=p(),y(Ne.$$.fragment),Ht=p(),Fe=h("p"),Fe.innerHTML=$s,It=p(),y(Se.$$.fragment),Et=p(),ze=h("p"),ze.innerHTML=js,Nt=p(),ce=h("h2"),ye=h("a"),ft=h("span"),y(Ye.$$.fragment),os=p(),at=h("span"),at.textContent=Ts,Ft=p(),y(Me.$$.fragment),St=p(),y(ge.$$.fragment),zt=p(),me=h("h2"),be=h("a"),ut=h("span"),y(Qe.$$.fragment),ps=p(),lt=h("span"),lt.textContent=_s,Yt=p(),qe=h("p"),qe.textContent=ks,Qt=p(),Ae=h("p"),Ae.textContent=Js,qt=p(),y(Le.$$.fragment),At=p(),Pe=h("p"),Pe.innerHTML=Us,Lt=p(),y(De.$$.fragment),Pt=p(),Ke=h("p"),Ke.innerHTML=vs,Dt=p(),y(we.$$.fragment),Kt=p(),dt=h("p"),this.h()},l(e){const r=Ys("svelte-1phssyn",document.head);a=f(r,"META",{name:!0,content:!0}),r.forEach(t),c=i(e),s=f(e,"P",{}),E(s).forEach(t),m=i(e),d=f(e,"H1",{class:!0});var Oe=E(d);k=f(Oe,"A",{id:!0,class:!0,href:!0});var yt=E(k);H=f(yt,"SPAN",{});var Mt=E(H);M(J.$$.fragment,Mt),Mt.forEach(t),yt.forEach(t),G=i(Oe),R=f(Oe,"SPAN",{"data-svelte-h":!0}),j(R)!=="svelte-qg4vk8"&&(R.textContent=B),Oe.forEach(t),N=i(e),M(C.$$.fragment,e),U=i(e),M(x.$$.fragment,e),o=i(e),_=f(e,"P",{"data-svelte-h":!0}),j(_)!=="svelte-x8f5ei"&&(_.textContent=Q),S=i(e),I=f(e,"P",{"data-svelte-h":!0}),j(I)!=="svelte-1aff4p7"&&(I.textContent=u),X=i(e),F=f(e,"OL",{"data-svelte-h":!0}),j(F)!=="svelte-1yi27h4"&&(F.innerHTML=ot),te=i(e),M(Y.$$.fragment,e),se=i(e),q=f(e,"P",{"data-svelte-h":!0}),j(q)!=="svelte-1c9nexd"&&(q.textContent=pt),ae=i(e),M(A.$$.fragment,e),le=i(e),L=f(e,"P",{"data-svelte-h":!0}),j(L)!=="svelte-k76o1m"&&(L.textContent=it),ne=i(e),M(P.$$.fragment,e),re=i(e),z=f(e,"H2",{class:!0});var et=E(z);O=f(et,"A",{id:!0,class:!0,href:!0});var gt=E(O);ee=f(gt,"SPAN",{});var Zs=E(ee);M(D.$$.fragment,Zs),Zs.forEach(t),gt.forEach(t),he=i(et),K=f(et,"SPAN",{"data-svelte-h":!0}),j(K)!=="svelte-9zawv2"&&(K.textContent=ct),et.forEach(t),oe=i(e),n=f(e,"P",{"data-svelte-h":!0}),j(n)!=="svelte-1r4htuf"&&(n.innerHTML=T),je=i(e),M(Te.$$.fragment,e),bt=i(e),_e=f(e,"P",{"data-svelte-h":!0}),j(_e)!=="svelte-gqiacy"&&(_e.innerHTML=cs),wt=i(e),M(ke.$$.fragment,e),$t=i(e),Je=f(e,"P",{"data-svelte-h":!0}),j(Je)!=="svelte-1m91ua0"&&(Je.textContent=ms),jt=i(e),M(Ue.$$.fragment,e),Tt=i(e),ve=f(e,"P",{"data-svelte-h":!0}),j(ve)!=="svelte-pj869u"&&(ve.innerHTML=hs),_t=i(e),pe=f(e,"H2",{class:!0});var es=E(pe);fe=f(es,"A",{id:!0,class:!0,href:!0});var Cs=E(fe);mt=f(Cs,"SPAN",{});var xs=E(mt);M(Ze.$$.fragment,xs),xs.forEach(t),Cs.forEach(t),ns=i(es),tt=f(es,"SPAN",{"data-svelte-h":!0}),j(tt)!=="svelte-1cg9qj"&&(tt.textContent=fs),es.forEach(t),kt=i(e),M(Ce.$$.fragment,e),Jt=i(e),xe=f(e,"P",{"data-svelte-h":!0}),j(xe)!=="svelte-1m3bu0h"&&(xe.textContent=us),Ut=i(e),M(Re.$$.fragment,e),vt=i(e),Be=f(e,"P",{"data-svelte-h":!0}),j(Be)!=="svelte-pduvot"&&(Be.textContent=ds),Zt=i(e),Xe=f(e,"OL",{"data-svelte-h":!0}),j(Xe)!=="svelte-18wa00d"&&(Xe.innerHTML=ys),Ct=i(e),M(Ge.$$.fragment,e),xt=i(e),We=f(e,"P",{"data-svelte-h":!0}),j(We)!=="svelte-ndcj3d"&&(We.innerHTML=Ms),Rt=i(e),M(Ve.$$.fragment,e),Bt=i(e),He=f(e,"P",{"data-svelte-h":!0}),j(He)!=="svelte-5dvr4x"&&(He.innerHTML=gs),Xt=i(e),M(ue.$$.fragment,e),Gt=i(e),ie=f(e,"H2",{class:!0});var ts=E(ie);de=f(ts,"A",{id:!0,class:!0,href:!0});var Rs=E(de);ht=f(Rs,"SPAN",{});var Bs=E(ht);M(Ie.$$.fragment,Bs),Bs.forEach(t),Rs.forEach(t),rs=i(ts),st=f(ts,"SPAN",{"data-svelte-h":!0}),j(st)!=="svelte-sh8s6s"&&(st.textContent=bs),ts.forEach(t),Wt=i(e),Ee=f(e,"P",{"data-svelte-h":!0}),j(Ee)!=="svelte-1mb37bt"&&(Ee.innerHTML=ws),Vt=i(e),M(Ne.$$.fragment,e),Ht=i(e),Fe=f(e,"P",{"data-svelte-h":!0}),j(Fe)!=="svelte-6tzthx"&&(Fe.innerHTML=$s),It=i(e),M(Se.$$.fragment,e),Et=i(e),ze=f(e,"P",{"data-svelte-h":!0}),j(ze)!=="svelte-183aynn"&&(ze.innerHTML=js),Nt=i(e),ce=f(e,"H2",{class:!0});var ss=E(ce);ye=f(ss,"A",{id:!0,class:!0,href:!0});var Xs=E(ye);ft=f(Xs,"SPAN",{});var Gs=E(ft);M(Ye.$$.fragment,Gs),Gs.forEach(t),Xs.forEach(t),os=i(ss),at=f(ss,"SPAN",{"data-svelte-h":!0}),j(at)!=="svelte-5arm0l"&&(at.textContent=Ts),ss.forEach(t),Ft=i(e),M(Me.$$.fragment,e),St=i(e),M(ge.$$.fragment,e),zt=i(e),me=f(e,"H2",{class:!0});var as=E(me);be=f(as,"A",{id:!0,class:!0,href:!0});var Ws=E(be);ut=f(Ws,"SPAN",{});var Vs=E(ut);M(Qe.$$.fragment,Vs),Vs.forEach(t),Ws.forEach(t),ps=i(as),lt=f(as,"SPAN",{"data-svelte-h":!0}),j(lt)!=="svelte-199uz7g"&&(lt.textContent=_s),as.forEach(t),Yt=i(e),qe=f(e,"P",{"data-svelte-h":!0}),j(qe)!=="svelte-633ppb"&&(qe.textContent=ks),Qt=i(e),Ae=f(e,"P",{"data-svelte-h":!0}),j(Ae)!=="svelte-1js4i9r"&&(Ae.textContent=Js),qt=i(e),M(Le.$$.fragment,e),At=i(e),Pe=f(e,"P",{"data-svelte-h":!0}),j(Pe)!=="svelte-4um69t"&&(Pe.innerHTML=Us),Lt=i(e),M(De.$$.fragment,e),Pt=i(e),Ke=f(e,"P",{"data-svelte-h":!0}),j(Ke)!=="svelte-1njl8vm"&&(Ke.innerHTML=vs),Dt=i(e),M(we.$$.fragment,e),Kt=i(e),dt=f(e,"P",{}),E(dt).forEach(t),this.h()},h(){W(a,"name","hf:doc:metadata"),W(a,"content",JSON.stringify(ca)),W(k,"id","translation"),W(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"),W(k,"href","#translation"),W(d,"class","relative group"),W(O,"id","load-opus-books-dataset"),W(O,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),W(O,"href","#load-opus-books-dataset"),W(z,"class","relative group"),W(fe,"id","preprocess"),W(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"),W(fe,"href","#preprocess"),W(pe,"class","relative group"),W(de,"id","evaluate"),W(de,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),W(de,"href","#evaluate"),W(ie,"class","relative group"),W(ye,"id","train"),W(ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),W(ye,"href","#train"),W(ce,"class","relative group"),W(be,"id","inference"),W(be,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),W(be,"href","#inference"),W(me,"class","relative group")},m(e,r){V(document.head,a),l(e,c,r),l(e,s,r),l(e,m,r),l(e,d,r),V(d,k),V(k,H),g(J,H,null),V(d,G),V(d,R),l(e,N,r),g(C,e,r),l(e,U,r),g(x,e,r),l(e,o,r),l(e,_,r),l(e,S,r),l(e,I,r),l(e,X,r),l(e,F,r),l(e,te,r),g(Y,e,r),l(e,se,r),l(e,q,r),l(e,ae,r),g(A,e,r),l(e,le,r),l(e,L,r),l(e,ne,r),g(P,e,r),l(e,re,r),l(e,z,r),V(z,O),V(O,ee),g(D,ee,null),V(z,he),V(z,K),l(e,oe,r),l(e,n,r),l(e,je,r),g(Te,e,r),l(e,bt,r),l(e,_e,r),l(e,wt,r),g(ke,e,r),l(e,$t,r),l(e,Je,r),l(e,jt,r),g(Ue,e,r),l(e,Tt,r),l(e,ve,r),l(e,_t,r),l(e,pe,r),V(pe,fe),V(fe,mt),g(Ze,mt,null),V(pe,ns),V(pe,tt),l(e,kt,r),g(Ce,e,r),l(e,Jt,r),l(e,xe,r),l(e,Ut,r),g(Re,e,r),l(e,vt,r),l(e,Be,r),l(e,Zt,r),l(e,Xe,r),l(e,Ct,r),g(Ge,e,r),l(e,xt,r),l(e,We,r),l(e,Rt,r),g(Ve,e,r),l(e,Bt,r),l(e,He,r),l(e,Xt,r),g(ue,e,r),l(e,Gt,r),l(e,ie,r),V(ie,de),V(de,ht),g(Ie,ht,null),V(ie,rs),V(ie,st),l(e,Wt,r),l(e,Ee,r),l(e,Vt,r),g(Ne,e,r),l(e,Ht,r),l(e,Fe,r),l(e,It,r),g(Se,e,r),l(e,Et,r),l(e,ze,r),l(e,Nt,r),l(e,ce,r),V(ce,ye),V(ye,ft),g(Ye,ft,null),V(ce,os),V(ce,at),l(e,Ft,r),g(Me,e,r),l(e,St,r),g(ge,e,r),l(e,zt,r),l(e,me,r),V(me,be),V(be,ut),g(Qe,ut,null),V(me,ps),V(me,lt),l(e,Yt,r),l(e,qe,r),l(e,Qt,r),l(e,Ae,r),l(e,qt,r),g(Le,e,r),l(e,At,r),l(e,Pe,r),l(e,Lt,r),g(De,e,r),l(e,Pt,r),l(e,Ke,r),l(e,Dt,r),g(we,e,r),l(e,Kt,r),l(e,dt,r),Ot=!0},p(e,[r]){const Oe={};r&2&&(Oe.$$scope={dirty:r,ctx:e}),Y.$set(Oe);const yt={};r&2&&(yt.$$scope={dirty:r,ctx:e}),ue.$set(yt);const Mt={};r&2&&(Mt.$$scope={dirty:r,ctx:e}),Me.$set(Mt);const et={};r&2&&(et.$$scope={dirty:r,ctx:e}),ge.$set(et);const gt={};r&2&&(gt.$$scope={dirty:r,ctx:e}),we.$set(gt)},i(e){Ot||(b(J.$$.fragment,e),b(C.$$.fragment,e),b(x.$$.fragment,e),b(Y.$$.fragment,e),b(A.$$.fragment,e),b(P.$$.fragment,e),b(D.$$.fragment,e),b(Te.$$.fragment,e),b(ke.$$.fragment,e),b(Ue.$$.fragment,e),b(Ze.$$.fragment,e),b(Ce.$$.fragment,e),b(Re.$$.fragment,e),b(Ge.$$.fragment,e),b(Ve.$$.fragment,e),b(ue.$$.fragment,e),b(Ie.$$.fragment,e),b(Ne.$$.fragment,e),b(Se.$$.fragment,e),b(Ye.$$.fragment,e),b(Me.$$.fragment,e),b(ge.$$.fragment,e),b(Qe.$$.fragment,e),b(Le.$$.fragment,e),b(De.$$.fragment,e),b(we.$$.fragment,e),Ot=!0)},o(e){w(J.$$.fragment,e),w(C.$$.fragment,e),w(x.$$.fragment,e),w(Y.$$.fragment,e),w(A.$$.fragment,e),w(P.$$.fragment,e),w(D.$$.fragment,e),w(Te.$$.fragment,e),w(ke.$$.fragment,e),w(Ue.$$.fragment,e),w(Ze.$$.fragment,e),w(Ce.$$.fragment,e),w(Re.$$.fragment,e),w(Ge.$$.fragment,e),w(Ve.$$.fragment,e),w(ue.$$.fragment,e),w(Ie.$$.fragment,e),w(Ne.$$.fragment,e),w(Se.$$.fragment,e),w(Ye.$$.fragment,e),w(Me.$$.fragment,e),w(ge.$$.fragment,e),w(Qe.$$.fragment,e),w(Le.$$.fragment,e),w(De.$$.fragment,e),w(we.$$.fragment,e),Ot=!1},d(e){e&&(t(c),t(s),t(m),t(d),t(N),t(U),t(o),t(_),t(S),t(I),t(X),t(F),t(te),t(se),t(q),t(ae),t(le),t(L),t(ne),t(re),t(z),t(oe),t(n),t(je),t(bt),t(_e),t(wt),t($t),t(Je),t(jt),t(Tt),t(ve),t(_t),t(pe),t(kt),t(Jt),t(xe),t(Ut),t(vt),t(Be),t(Zt),t(Xe),t(Ct),t(xt),t(We),t(Rt),t(Bt),t(He),t(Xt),t(Gt),t(ie),t(Wt),t(Ee),t(Vt),t(Ht),t(Fe),t(It),t(Et),t(ze),t(Nt),t(ce),t(Ft),t(St),t(zt),t(me),t(Yt),t(qe),t(Qt),t(Ae),t(qt),t(At),t(Pe),t(Lt),t(Pt),t(Ke),t(Dt),t(Kt),t(dt)),t(a),$(J),$(C,e),$(x,e),$(Y,e),$(A,e),$(P,e),$(D),$(Te,e),$(ke,e),$(Ue,e),$(Ze),$(Ce,e),$(Re,e),$(Ge,e),$(Ve,e),$(ue,e),$(Ie),$(Ne,e),$(Se,e),$(Ye),$(Me,e),$(ge,e),$(Qe),$(Le,e),$(De,e),$(we,e)}}}const ca={local:"translation",sections:[{local:"load-opus-books-dataset",title:"Load OPUS Books dataset"},{local:"preprocess",title:"Preprocess"},{local:"evaluate",title:"Evaluate"},{local:"train",title:"Train"},{local:"inference",title:"Inference"}],title:"Translation"};function ma(v){return Fs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class wa extends Ss{constructor(a){super(),zs(this,a,ma,ia,Ns,{})}}export{wa as component};
