import{s as Yt,o as Qt,n as ie}from"../chunks/scheduler.9bc65507.js";import{S as qt,i as At,g as $,s as p,r as u,A as Lt,h as w,f as a,c as i,j as Ft,u as h,x as T,k as Nt,y as Pt,a as l,v as d,d as y,t as M,w as g,m as Et,n as St}from"../chunks/index.707bf1b6.js";import{T as $t}from"../chunks/Tip.c2ecdbf4.js";import{Y as zt}from"../chunks/Youtube.e1129c6f.js";import{C as x}from"../chunks/CodeBlock.54a9f38d.js";import{D as Dt}from"../chunks/DocNotebookDropdown.3e6b3817.js";import{F as wt,M as ze}from"../chunks/Markdown.fef84341.js";import{H as Ne}from"../chunks/Heading.342b1fa6.js";function Kt(k){let s,m,t='<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/seamless_m4t">SeamlessM4T</a>, <a href="../model_doc/seamless_m4t_v2">SeamlessM4Tv2</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(){s=Et(`The task illustrated in this tutorial is supported by the following model architectures:

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

`),m=w(c,"P",{"data-svelte-h":!0}),T(m)!=="svelte-1s35ylz"&&(m.innerHTML=t)},m(c,b){l(c,s,b),l(c,m,b)},p:ie,d(c){c&&(a(s),a(m))}}}function Ot(k){let s,m;return s=new x({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(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p:ie,i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function es(k){let s,m;return s=new ze({props:{$$slots:{default:[Ot]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ts(k){let s,m;return s=new x({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(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p:ie,i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ss(k){let s,m;return s=new ze({props:{$$slots:{default:[ts]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function as(k){let s,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/v4.37.1/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(){s=$("p"),s.innerHTML=m},l(t){s=w(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1h7we9o"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function ls(k){let s,m,t,c='You’re ready to start training your model now! Load T5 with <a href="/docs/transformers/v4.37.1/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a>:',b,Z,W,R,v="At this point, only three steps remain:",B,U,I='<li>Define your training hyperparameters in <a href="/docs/transformers/v4.37.1/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.37.1/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.37.1/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.37.1/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',X,J,G,o,_='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/v4.37.1/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',F,H,V;return s=new $t({props:{$$slots:{default:[as]},$$scope:{ctx:k}}}),Z=new x({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}}),J=new x({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}}),H=new x({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.push_to_hub()',wrap:!1}}),{c(){u(s.$$.fragment),m=p(),t=$("p"),t.innerHTML=c,b=p(),u(Z.$$.fragment),W=p(),R=$("p"),R.textContent=v,B=p(),U=$("ol"),U.innerHTML=I,X=p(),u(J.$$.fragment),G=p(),o=$("p"),o.innerHTML=_,F=p(),u(H.$$.fragment)},l(f){h(s.$$.fragment,f),m=i(f),t=w(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-3vg4oh"&&(t.innerHTML=c),b=i(f),h(Z.$$.fragment,f),W=i(f),R=w(f,"P",{"data-svelte-h":!0}),T(R)!=="svelte-l42k0i"&&(R.textContent=v),B=i(f),U=w(f,"OL",{"data-svelte-h":!0}),T(U)!=="svelte-osncio"&&(U.innerHTML=I),X=i(f),h(J.$$.fragment,f),G=i(f),o=w(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-2z2sfm"&&(o.innerHTML=_),F=i(f),h(H.$$.fragment,f)},m(f,C){d(s,f,C),l(f,m,C),l(f,t,C),l(f,b,C),d(Z,f,C),l(f,W,C),l(f,R,C),l(f,B,C),l(f,U,C),l(f,X,C),d(J,f,C),l(f,G,C),l(f,o,C),l(f,F,C),d(H,f,C),V=!0},p(f,C){const N={};C&2&&(N.$$scope={dirty:C,ctx:f}),s.$set(N)},i(f){V||(y(s.$$.fragment,f),y(Z.$$.fragment,f),y(J.$$.fragment,f),y(H.$$.fragment,f),V=!0)},o(f){M(s.$$.fragment,f),M(Z.$$.fragment,f),M(J.$$.fragment,f),M(H.$$.fragment,f),V=!1},d(f){f&&(a(m),a(t),a(b),a(W),a(R),a(B),a(U),a(X),a(G),a(o),a(F)),g(s,f),g(Z,f),g(J,f),g(H,f)}}}function ns(k){let s,m;return s=new ze({props:{$$slots:{default:[ls]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function rs(k){let s,m='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(){s=$("p"),s.innerHTML=m},l(t){s=w(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1rd4nl8"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function os(k){let s,m,t,c,b,Z='Then you can load T5 with <a href="/docs/transformers/v4.37.1/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a>:',W,R,v,B,U='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/v4.37.1/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',I,X,J,G,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:',_,F,H,V,f='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>.',C,N,me='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/v4.37.1/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',z,E,S,te,ce='Specify where to push your model and tokenizer in the <a href="/docs/transformers/v4.37.1/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',Y,Q,q,A,se="Then bundle your callbacks together:",fe,L,P,D,ae='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:',ue,K,O,ee,le="Once training is completed, your model is automatically uploaded to the Hub so everyone can use it!",he;return s=new $t({props:{$$slots:{default:[rs]},$$scope:{ctx:k}}}),t=new x({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}}),R=new x({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}}),X=new x({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}}),F=new x({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}}),E=new x({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}}),Q=new x({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}}),L=new x({props:{code:"Y2FsbGJhY2tzJTIwJTNEJTIwJTVCbWV0cmljX2NhbGxiYWNrJTJDJTIwcHVzaF90b19odWJfY2FsbGJhY2slNUQ=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>callbacks = [metric_callback, push_to_hub_callback]',wrap:!1}}),K=new x({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(){u(s.$$.fragment),m=Et(`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),u(t.$$.fragment),c=p(),b=$("p"),b.innerHTML=Z,W=p(),u(R.$$.fragment),v=p(),B=$("p"),B.innerHTML=U,I=p(),u(X.$$.fragment),J=p(),G=$("p"),G.innerHTML=o,_=p(),u(F.$$.fragment),H=p(),V=$("p"),V.innerHTML=f,C=p(),N=$("p"),N.innerHTML=me,z=p(),u(E.$$.fragment),S=p(),te=$("p"),te.innerHTML=ce,Y=p(),u(Q.$$.fragment),q=p(),A=$("p"),A.textContent=se,fe=p(),u(L.$$.fragment),P=p(),D=$("p"),D.innerHTML=ae,ue=p(),u(K.$$.fragment),O=p(),ee=$("p"),ee.textContent=le},l(r){h(s.$$.fragment,r),m=St(r,`
To finetune a model in TensorFlow, start by setting up an optimizer function, learning rate schedule, and some training hyperparameters:

	`),h(t.$$.fragment,r),c=i(r),b=w(r,"P",{"data-svelte-h":!0}),T(b)!=="svelte-1ray13r"&&(b.innerHTML=Z),W=i(r),h(R.$$.fragment,r),v=i(r),B=w(r,"P",{"data-svelte-h":!0}),T(B)!=="svelte-15mx34r"&&(B.innerHTML=U),I=i(r),h(X.$$.fragment,r),J=i(r),G=w(r,"P",{"data-svelte-h":!0}),T(G)!=="svelte-17cxx5e"&&(G.innerHTML=o),_=i(r),h(F.$$.fragment,r),H=i(r),V=w(r,"P",{"data-svelte-h":!0}),T(V)!=="svelte-13cue08"&&(V.innerHTML=f),C=i(r),N=w(r,"P",{"data-svelte-h":!0}),T(N)!=="svelte-1atvv5b"&&(N.innerHTML=me),z=i(r),h(E.$$.fragment,r),S=i(r),te=w(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-1z0pe3"&&(te.innerHTML=ce),Y=i(r),h(Q.$$.fragment,r),q=i(r),A=w(r,"P",{"data-svelte-h":!0}),T(A)!=="svelte-1lw9xm8"&&(A.textContent=se),fe=i(r),h(L.$$.fragment,r),P=i(r),D=w(r,"P",{"data-svelte-h":!0}),T(D)!=="svelte-1hrpv1v"&&(D.innerHTML=ae),ue=i(r),h(K.$$.fragment,r),O=i(r),ee=w(r,"P",{"data-svelte-h":!0}),T(ee)!=="svelte-2s71om"&&(ee.textContent=le)},m(r,j){d(s,r,j),l(r,m,j),d(t,r,j),l(r,c,j),l(r,b,j),l(r,W,j),d(R,r,j),l(r,v,j),l(r,B,j),l(r,I,j),d(X,r,j),l(r,J,j),l(r,G,j),l(r,_,j),d(F,r,j),l(r,H,j),l(r,V,j),l(r,C,j),l(r,N,j),l(r,z,j),d(E,r,j),l(r,S,j),l(r,te,j),l(r,Y,j),d(Q,r,j),l(r,q,j),l(r,A,j),l(r,fe,j),d(L,r,j),l(r,P,j),l(r,D,j),l(r,ue,j),d(K,r,j),l(r,O,j),l(r,ee,j),he=!0},p(r,j){const de={};j&2&&(de.$$scope={dirty:j,ctx:r}),s.$set(de)},i(r){he||(y(s.$$.fragment,r),y(t.$$.fragment,r),y(R.$$.fragment,r),y(X.$$.fragment,r),y(F.$$.fragment,r),y(E.$$.fragment,r),y(Q.$$.fragment,r),y(L.$$.fragment,r),y(K.$$.fragment,r),he=!0)},o(r){M(s.$$.fragment,r),M(t.$$.fragment,r),M(R.$$.fragment,r),M(X.$$.fragment,r),M(F.$$.fragment,r),M(E.$$.fragment,r),M(Q.$$.fragment,r),M(L.$$.fragment,r),M(K.$$.fragment,r),he=!1},d(r){r&&(a(m),a(c),a(b),a(W),a(v),a(B),a(I),a(J),a(G),a(_),a(H),a(V),a(C),a(N),a(z),a(S),a(te),a(Y),a(q),a(A),a(fe),a(P),a(D),a(ue),a(O),a(ee)),g(s,r),g(t,r),g(R,r),g(X,r),g(F,r),g(E,r),g(Q,r),g(L,r),g(K,r)}}}function ps(k){let s,m;return s=new ze({props:{$$slots:{default:[os]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function is(k){let s,m=`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(){s=$("p"),s.innerHTML=m},l(t){s=w(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-ikyjb6"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function ms(k){let s,m="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",t,c,b,Z,W='Use the <a href="/docs/transformers/v4.37.1/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.',R,v,B,U,I="Decode the generated token ids back into text:",X,J,G;return c=new x({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}}),v=new x({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}}),J=new x({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(){s=$("p"),s.innerHTML=m,t=p(),u(c.$$.fragment),b=p(),Z=$("p"),Z.innerHTML=W,R=p(),u(v.$$.fragment),B=p(),U=$("p"),U.textContent=I,X=p(),u(J.$$.fragment)},l(o){s=w(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1c2y1ia"&&(s.innerHTML=m),t=i(o),h(c.$$.fragment,o),b=i(o),Z=w(o,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-t5u0ea"&&(Z.innerHTML=W),R=i(o),h(v.$$.fragment,o),B=i(o),U=w(o,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1918fu9"&&(U.textContent=I),X=i(o),h(J.$$.fragment,o)},m(o,_){l(o,s,_),l(o,t,_),d(c,o,_),l(o,b,_),l(o,Z,_),l(o,R,_),d(v,o,_),l(o,B,_),l(o,U,_),l(o,X,_),d(J,o,_),G=!0},p:ie,i(o){G||(y(c.$$.fragment,o),y(v.$$.fragment,o),y(J.$$.fragment,o),G=!0)},o(o){M(c.$$.fragment,o),M(v.$$.fragment,o),M(J.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(B),a(U),a(X)),g(c,o),g(v,o),g(J,o)}}}function cs(k){let s,m;return s=new ze({props:{$$slots:{default:[ms]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function fs(k){let s,m="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",t,c,b,Z,W='Use the <a href="/docs/transformers/v4.37.1/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.',R,v,B,U,I="Decode the generated token ids back into text:",X,J,G;return c=new x({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}}),v=new x({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}}),J=new x({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(){s=$("p"),s.innerHTML=m,t=p(),u(c.$$.fragment),b=p(),Z=$("p"),Z.innerHTML=W,R=p(),u(v.$$.fragment),B=p(),U=$("p"),U.textContent=I,X=p(),u(J.$$.fragment)},l(o){s=w(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-hw2mu6"&&(s.innerHTML=m),t=i(o),h(c.$$.fragment,o),b=i(o),Z=w(o,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-1nx431o"&&(Z.innerHTML=W),R=i(o),h(v.$$.fragment,o),B=i(o),U=w(o,"P",{"data-svelte-h":!0}),T(U)!=="svelte-1918fu9"&&(U.textContent=I),X=i(o),h(J.$$.fragment,o)},m(o,_){l(o,s,_),l(o,t,_),d(c,o,_),l(o,b,_),l(o,Z,_),l(o,R,_),d(v,o,_),l(o,B,_),l(o,U,_),l(o,X,_),d(J,o,_),G=!0},p:ie,i(o){G||(y(c.$$.fragment,o),y(v.$$.fragment,o),y(J.$$.fragment,o),G=!0)},o(o){M(c.$$.fragment,o),M(v.$$.fragment,o),M(J.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(B),a(U),a(X)),g(c,o),g(v,o),g(J,o)}}}function us(k){let s,m;return s=new ze({props:{$$slots:{default:[fs]},$$scope:{ctx:k}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){d(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function hs(k){let s,m,t,c,b,Z,W,R,v,B,U,I="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.",X,J,G="This guide will show you how to:",o,_,F='<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>',H,V,f,C,N="Before you begin, make sure you have all the necessary libraries installed:",me,z,E,S,te="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:",ce,Y,Q,q,A,se,fe='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:',L,P,D,ae,ue='Split the dataset into a train and test set with the <a href="https://huggingface.co/docs/datasets/v2.16.1/en/package_reference/main_classes#datasets.Dataset.train_test_split" rel="nofollow">train_test_split</a> method:',K,O,ee,le,he="Then take a look at an example:",r,j,de,ye,jt="<code>translation</code>: an English and French translation of the text.",Se,Me,Ye,ge,Qe,be,Tt="The next step is to load a T5 tokenizer to process the English-French language pairs:",qe,$e,Ae,we,_t="The preprocessing function you want to create needs to:",Le,je,Jt="<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>",Pe,Te,De,_e,Ut='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/v2.16.1/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:',Ke,Je,Oe,Ue,kt='Now create a batch of examples using <a href="/docs/transformers/v4.37.1/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.',et,ne,tt,ke,st,Ze,Zt='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):',at,ve,lt,Ce,vt="Then create a function that passes your predictions and labels to <code>compute</code> to calculate the SacreBLEU score:",nt,xe,rt,Re,Ct="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",ot,Be,pt,re,it,oe,mt,Xe,ct,Ge,xt="Great, now that you’ve finetuned a model, you can use it for inference!",ft,We,Rt="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:",ut,Ve,ht,He,Bt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/v4.37.1/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for translation with your model, and pass your text to it:',dt,Ie,yt,Fe,Xt="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",Mt,pe,gt,Ee,bt;return b=new Ne({props:{title:"Translation",local:"translation",headingTag:"h1"}}),W=new Dt({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"}]}}),v=new zt({props:{id:"1JvfrvZgi6c"}}),V=new $t({props:{$$slots:{default:[Kt]},$$scope:{ctx:k}}}),z=new x({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBzYWNyZWJsZXU=",highlighted:"pip install transformers datasets evaluate sacrebleu",wrap:!1}}),Y=new x({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}}),q=new Ne({props:{title:"Load OPUS Books dataset",local:"load-opus-books-dataset",headingTag:"h2"}}),P=new x({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}}),O=new x({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}}),j=new x({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}}),Me=new Ne({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),ge=new zt({props:{id:"XAR8jnZZuUs"}}),$e=new x({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}}),Te=new x({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}}),Je=new x({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}}),ne=new wt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ss],pytorch:[es]},$$scope:{ctx:k}}}),ke=new Ne({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),ve=new x({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}}),xe=new x({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}}),Be=new Ne({props:{title:"Train",local:"train",headingTag:"h2"}}),re=new wt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ps],pytorch:[ns]},$$scope:{ctx:k}}}),oe=new $t({props:{$$slots:{default:[is]},$$scope:{ctx:k}}}),Xe=new Ne({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Ve=new x({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}}),Ie=new x({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}}),pe=new wt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[us],pytorch:[cs]},$$scope:{ctx:k}}}),{c(){s=$("meta"),m=p(),t=$("p"),c=p(),u(b.$$.fragment),Z=p(),u(W.$$.fragment),R=p(),u(v.$$.fragment),B=p(),U=$("p"),U.textContent=I,X=p(),J=$("p"),J.textContent=G,o=p(),_=$("ol"),_.innerHTML=F,H=p(),u(V.$$.fragment),f=p(),C=$("p"),C.textContent=N,me=p(),u(z.$$.fragment),E=p(),S=$("p"),S.textContent=te,ce=p(),u(Y.$$.fragment),Q=p(),u(q.$$.fragment),A=p(),se=$("p"),se.innerHTML=fe,L=p(),u(P.$$.fragment),D=p(),ae=$("p"),ae.innerHTML=ue,K=p(),u(O.$$.fragment),ee=p(),le=$("p"),le.textContent=he,r=p(),u(j.$$.fragment),de=p(),ye=$("p"),ye.innerHTML=jt,Se=p(),u(Me.$$.fragment),Ye=p(),u(ge.$$.fragment),Qe=p(),be=$("p"),be.textContent=Tt,qe=p(),u($e.$$.fragment),Ae=p(),we=$("p"),we.textContent=_t,Le=p(),je=$("ol"),je.innerHTML=Jt,Pe=p(),u(Te.$$.fragment),De=p(),_e=$("p"),_e.innerHTML=Ut,Ke=p(),u(Je.$$.fragment),Oe=p(),Ue=$("p"),Ue.innerHTML=kt,et=p(),u(ne.$$.fragment),tt=p(),u(ke.$$.fragment),st=p(),Ze=$("p"),Ze.innerHTML=Zt,at=p(),u(ve.$$.fragment),lt=p(),Ce=$("p"),Ce.innerHTML=vt,nt=p(),u(xe.$$.fragment),rt=p(),Re=$("p"),Re.innerHTML=Ct,ot=p(),u(Be.$$.fragment),pt=p(),u(re.$$.fragment),it=p(),u(oe.$$.fragment),mt=p(),u(Xe.$$.fragment),ct=p(),Ge=$("p"),Ge.textContent=xt,ft=p(),We=$("p"),We.textContent=Rt,ut=p(),u(Ve.$$.fragment),ht=p(),He=$("p"),He.innerHTML=Bt,dt=p(),u(Ie.$$.fragment),yt=p(),Fe=$("p"),Fe.innerHTML=Xt,Mt=p(),u(pe.$$.fragment),gt=p(),Ee=$("p"),this.h()},l(e){const n=Lt("svelte-u9bgzb",document.head);s=w(n,"META",{name:!0,content:!0}),n.forEach(a),m=i(e),t=w(e,"P",{}),Ft(t).forEach(a),c=i(e),h(b.$$.fragment,e),Z=i(e),h(W.$$.fragment,e),R=i(e),h(v.$$.fragment,e),B=i(e),U=w(e,"P",{"data-svelte-h":!0}),T(U)!=="svelte-x8f5ei"&&(U.textContent=I),X=i(e),J=w(e,"P",{"data-svelte-h":!0}),T(J)!=="svelte-1aff4p7"&&(J.textContent=G),o=i(e),_=w(e,"OL",{"data-svelte-h":!0}),T(_)!=="svelte-1yi27h4"&&(_.innerHTML=F),H=i(e),h(V.$$.fragment,e),f=i(e),C=w(e,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1c9nexd"&&(C.textContent=N),me=i(e),h(z.$$.fragment,e),E=i(e),S=w(e,"P",{"data-svelte-h":!0}),T(S)!=="svelte-k76o1m"&&(S.textContent=te),ce=i(e),h(Y.$$.fragment,e),Q=i(e),h(q.$$.fragment,e),A=i(e),se=w(e,"P",{"data-svelte-h":!0}),T(se)!=="svelte-1r4htuf"&&(se.innerHTML=fe),L=i(e),h(P.$$.fragment,e),D=i(e),ae=w(e,"P",{"data-svelte-h":!0}),T(ae)!=="svelte-r05ffc"&&(ae.innerHTML=ue),K=i(e),h(O.$$.fragment,e),ee=i(e),le=w(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-1m91ua0"&&(le.textContent=he),r=i(e),h(j.$$.fragment,e),de=i(e),ye=w(e,"P",{"data-svelte-h":!0}),T(ye)!=="svelte-pj869u"&&(ye.innerHTML=jt),Se=i(e),h(Me.$$.fragment,e),Ye=i(e),h(ge.$$.fragment,e),Qe=i(e),be=w(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-1m3bu0h"&&(be.textContent=Tt),qe=i(e),h($e.$$.fragment,e),Ae=i(e),we=w(e,"P",{"data-svelte-h":!0}),T(we)!=="svelte-pduvot"&&(we.textContent=_t),Le=i(e),je=w(e,"OL",{"data-svelte-h":!0}),T(je)!=="svelte-18wa00d"&&(je.innerHTML=Jt),Pe=i(e),h(Te.$$.fragment,e),De=i(e),_e=w(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-ph6b2z"&&(_e.innerHTML=Ut),Ke=i(e),h(Je.$$.fragment,e),Oe=i(e),Ue=w(e,"P",{"data-svelte-h":!0}),T(Ue)!=="svelte-eg74jf"&&(Ue.innerHTML=kt),et=i(e),h(ne.$$.fragment,e),tt=i(e),h(ke.$$.fragment,e),st=i(e),Ze=w(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1mb37bt"&&(Ze.innerHTML=Zt),at=i(e),h(ve.$$.fragment,e),lt=i(e),Ce=w(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-unu95e"&&(Ce.innerHTML=vt),nt=i(e),h(xe.$$.fragment,e),rt=i(e),Re=w(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-183aynn"&&(Re.innerHTML=Ct),ot=i(e),h(Be.$$.fragment,e),pt=i(e),h(re.$$.fragment,e),it=i(e),h(oe.$$.fragment,e),mt=i(e),h(Xe.$$.fragment,e),ct=i(e),Ge=w(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-633ppb"&&(Ge.textContent=xt),ft=i(e),We=w(e,"P",{"data-svelte-h":!0}),T(We)!=="svelte-1js4i9r"&&(We.textContent=Rt),ut=i(e),h(Ve.$$.fragment,e),ht=i(e),He=w(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-1646wxv"&&(He.innerHTML=Bt),dt=i(e),h(Ie.$$.fragment,e),yt=i(e),Fe=w(e,"P",{"data-svelte-h":!0}),T(Fe)!=="svelte-1njl8vm"&&(Fe.innerHTML=Xt),Mt=i(e),h(pe.$$.fragment,e),gt=i(e),Ee=w(e,"P",{}),Ft(Ee).forEach(a),this.h()},h(){Nt(s,"name","hf:doc:metadata"),Nt(s,"content",ds)},m(e,n){Pt(document.head,s),l(e,m,n),l(e,t,n),l(e,c,n),d(b,e,n),l(e,Z,n),d(W,e,n),l(e,R,n),d(v,e,n),l(e,B,n),l(e,U,n),l(e,X,n),l(e,J,n),l(e,o,n),l(e,_,n),l(e,H,n),d(V,e,n),l(e,f,n),l(e,C,n),l(e,me,n),d(z,e,n),l(e,E,n),l(e,S,n),l(e,ce,n),d(Y,e,n),l(e,Q,n),d(q,e,n),l(e,A,n),l(e,se,n),l(e,L,n),d(P,e,n),l(e,D,n),l(e,ae,n),l(e,K,n),d(O,e,n),l(e,ee,n),l(e,le,n),l(e,r,n),d(j,e,n),l(e,de,n),l(e,ye,n),l(e,Se,n),d(Me,e,n),l(e,Ye,n),d(ge,e,n),l(e,Qe,n),l(e,be,n),l(e,qe,n),d($e,e,n),l(e,Ae,n),l(e,we,n),l(e,Le,n),l(e,je,n),l(e,Pe,n),d(Te,e,n),l(e,De,n),l(e,_e,n),l(e,Ke,n),d(Je,e,n),l(e,Oe,n),l(e,Ue,n),l(e,et,n),d(ne,e,n),l(e,tt,n),d(ke,e,n),l(e,st,n),l(e,Ze,n),l(e,at,n),d(ve,e,n),l(e,lt,n),l(e,Ce,n),l(e,nt,n),d(xe,e,n),l(e,rt,n),l(e,Re,n),l(e,ot,n),d(Be,e,n),l(e,pt,n),d(re,e,n),l(e,it,n),d(oe,e,n),l(e,mt,n),d(Xe,e,n),l(e,ct,n),l(e,Ge,n),l(e,ft,n),l(e,We,n),l(e,ut,n),d(Ve,e,n),l(e,ht,n),l(e,He,n),l(e,dt,n),d(Ie,e,n),l(e,yt,n),l(e,Fe,n),l(e,Mt,n),d(pe,e,n),l(e,gt,n),l(e,Ee,n),bt=!0},p(e,[n]){const Gt={};n&2&&(Gt.$$scope={dirty:n,ctx:e}),V.$set(Gt);const Wt={};n&2&&(Wt.$$scope={dirty:n,ctx:e}),ne.$set(Wt);const Vt={};n&2&&(Vt.$$scope={dirty:n,ctx:e}),re.$set(Vt);const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),oe.$set(Ht);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),pe.$set(It)},i(e){bt||(y(b.$$.fragment,e),y(W.$$.fragment,e),y(v.$$.fragment,e),y(V.$$.fragment,e),y(z.$$.fragment,e),y(Y.$$.fragment,e),y(q.$$.fragment,e),y(P.$$.fragment,e),y(O.$$.fragment,e),y(j.$$.fragment,e),y(Me.$$.fragment,e),y(ge.$$.fragment,e),y($e.$$.fragment,e),y(Te.$$.fragment,e),y(Je.$$.fragment,e),y(ne.$$.fragment,e),y(ke.$$.fragment,e),y(ve.$$.fragment,e),y(xe.$$.fragment,e),y(Be.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(Xe.$$.fragment,e),y(Ve.$$.fragment,e),y(Ie.$$.fragment,e),y(pe.$$.fragment,e),bt=!0)},o(e){M(b.$$.fragment,e),M(W.$$.fragment,e),M(v.$$.fragment,e),M(V.$$.fragment,e),M(z.$$.fragment,e),M(Y.$$.fragment,e),M(q.$$.fragment,e),M(P.$$.fragment,e),M(O.$$.fragment,e),M(j.$$.fragment,e),M(Me.$$.fragment,e),M(ge.$$.fragment,e),M($e.$$.fragment,e),M(Te.$$.fragment,e),M(Je.$$.fragment,e),M(ne.$$.fragment,e),M(ke.$$.fragment,e),M(ve.$$.fragment,e),M(xe.$$.fragment,e),M(Be.$$.fragment,e),M(re.$$.fragment,e),M(oe.$$.fragment,e),M(Xe.$$.fragment,e),M(Ve.$$.fragment,e),M(Ie.$$.fragment,e),M(pe.$$.fragment,e),bt=!1},d(e){e&&(a(m),a(t),a(c),a(Z),a(R),a(B),a(U),a(X),a(J),a(o),a(_),a(H),a(f),a(C),a(me),a(E),a(S),a(ce),a(Q),a(A),a(se),a(L),a(D),a(ae),a(K),a(ee),a(le),a(r),a(de),a(ye),a(Se),a(Ye),a(Qe),a(be),a(qe),a(Ae),a(we),a(Le),a(je),a(Pe),a(De),a(_e),a(Ke),a(Oe),a(Ue),a(et),a(tt),a(st),a(Ze),a(at),a(lt),a(Ce),a(nt),a(rt),a(Re),a(ot),a(pt),a(it),a(mt),a(ct),a(Ge),a(ft),a(We),a(ut),a(ht),a(He),a(dt),a(yt),a(Fe),a(Mt),a(gt),a(Ee)),a(s),g(b,e),g(W,e),g(v,e),g(V,e),g(z,e),g(Y,e),g(q,e),g(P,e),g(O,e),g(j,e),g(Me,e),g(ge,e),g($e,e),g(Te,e),g(Je,e),g(ne,e),g(ke,e),g(ve,e),g(xe,e),g(Be,e),g(re,e),g(oe,e),g(Xe,e),g(Ve,e),g(Ie,e),g(pe,e)}}}const ds='{"title":"Translation","local":"translation","sections":[{"title":"Load OPUS Books dataset","local":"load-opus-books-dataset","sections":[],"depth":2},{"title":"Preprocess","local":"preprocess","sections":[],"depth":2},{"title":"Evaluate","local":"evaluate","sections":[],"depth":2},{"title":"Train","local":"train","sections":[],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2}],"depth":1}';function ys(k){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Js extends qt{constructor(s){super(),At(this,s,ys,hs,Yt,{})}}export{Js as component};
