import{s as St,o as Qt,n as ie}from"../chunks/scheduler.25b97de1.js";import{S as qt,i as At,g as $,s as p,r as u,A as Lt,h as j,f as a,c as i,j as Nt,u as h,x as T,k as zt,y as Pt,a as l,v as y,d as M,t as d,w as g,m as Dt,n as Kt}from"../chunks/index.d9030fc9.js";import{T as wt}from"../chunks/Tip.baa67368.js";import{Y as Yt}from"../chunks/Youtube.eaf1a617.js";import{C as x}from"../chunks/CodeBlock.e6cd0d95.js";import{D as Ot}from"../chunks/DocNotebookDropdown.5ea6cb78.js";import{F as Tt,M as ze}from"../chunks/Markdown.7217f838.js";import{H as Ne,E as es}from"../chunks/EditOnGithub.91d95064.js";function ts(J){let s,m='To see all architectures and checkpoints compatible with this task, we recommend checking the <a href="https://huggingface.co/tasks/translation" rel="nofollow">task-page</a>.';return{c(){s=$("p"),s.innerHTML=m},l(t){s=j(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-m8ly5d"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function ss(J){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){y(s,t,c),m=!0},p:ie,i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function as(J){let s,m;return s=new ze({props:{$$slots:{default:[ss]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ls(J){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){y(s,t,c),m=!0},p:ie,i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ns(J){let s,m;return s=new ze({props:{$$slots:{default:[ls]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function rs(J){let s,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_29969/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=j(t,"P",{"data-svelte-h":!0}),T(s)!=="svelte-9sclpj"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function os(J){let s,m,t,c='You’re ready to start training your model now! Load T5 with <a href="/docs/transformers/pr_29969/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a>:',b,Z,B,R,C="At this point, only three steps remain:",X,_,H='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_29969/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/pr_29969/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/pr_29969/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/pr_29969/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',W,k,G,o,U='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/pr_29969/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',E,F,V;return s=new wt({props:{$$slots:{default:[rs]},$$scope:{ctx:J}}}),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}}),k=new x({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIybXlfYXdlc29tZV9vcHVzX2Jvb2tzX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rfd2l0aF9nZW5lcmF0ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUyMCUyM2NoYW5nZSUyMHRvJTIwYmYxNiUzRFRydWUlMjBmb3IlMjBYUFUlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfYm9va3MlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRHRva2VuaXplZF9ib29rcyU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMGNvbXB1dGVfbWV0cmljcyUzRGNvbXB1dGVfbWV0cmljcyUyQyUwQSklMEElMEF0cmFpbmVyLnRyYWluKCk=",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>    eval_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-comment">#change to bf16=True for XPU</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}}),F=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),B=p(),R=$("p"),R.textContent=C,X=p(),_=$("ol"),_.innerHTML=H,W=p(),u(k.$$.fragment),G=p(),o=$("p"),o.innerHTML=U,E=p(),u(F.$$.fragment)},l(f){h(s.$$.fragment,f),m=i(f),t=j(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-1c47yjm"&&(t.innerHTML=c),b=i(f),h(Z.$$.fragment,f),B=i(f),R=j(f,"P",{"data-svelte-h":!0}),T(R)!=="svelte-l42k0i"&&(R.textContent=C),X=i(f),_=j(f,"OL",{"data-svelte-h":!0}),T(_)!=="svelte-ydpf4g"&&(_.innerHTML=H),W=i(f),h(k.$$.fragment,f),G=i(f),o=j(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-jpge3p"&&(o.innerHTML=U),E=i(f),h(F.$$.fragment,f)},m(f,v){y(s,f,v),l(f,m,v),l(f,t,v),l(f,b,v),y(Z,f,v),l(f,B,v),l(f,R,v),l(f,X,v),l(f,_,v),l(f,W,v),y(k,f,v),l(f,G,v),l(f,o,v),l(f,E,v),y(F,f,v),V=!0},p(f,v){const I={};v&2&&(I.$$scope={dirty:v,ctx:f}),s.$set(I)},i(f){V||(M(s.$$.fragment,f),M(Z.$$.fragment,f),M(k.$$.fragment,f),M(F.$$.fragment,f),V=!0)},o(f){d(s.$$.fragment,f),d(Z.$$.fragment,f),d(k.$$.fragment,f),d(F.$$.fragment,f),V=!1},d(f){f&&(a(m),a(t),a(b),a(B),a(R),a(X),a(_),a(W),a(G),a(o),a(E)),g(s,f),g(Z,f),g(k,f),g(F,f)}}}function ps(J){let s,m;return s=new ze({props:{$$slots:{default:[os]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function is(J){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=j(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 ms(J){let s,m,t,c,b,Z='Then you can load T5 with <a href="/docs/transformers/pr_29969/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a>:',B,R,C,X,_='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/pr_29969/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',H,W,k,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:',U,E,F,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>.',v,I,me='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/pr_29969/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',N,z,Y,te,ce='Specify where to push your model and tokenizer in the <a href="/docs/transformers/pr_29969/en/main_classes/keras_callbacks#transformers.PushToHubCallback">PushToHubCallback</a>:',S,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 wt({props:{$$slots:{default:[is]},$$scope:{ctx:J}}}),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}}),W=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}}),E=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}}),z=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=Dt(`
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,B=p(),u(R.$$.fragment),C=p(),X=$("p"),X.innerHTML=_,H=p(),u(W.$$.fragment),k=p(),G=$("p"),G.innerHTML=o,U=p(),u(E.$$.fragment),F=p(),V=$("p"),V.innerHTML=f,v=p(),I=$("p"),I.innerHTML=me,N=p(),u(z.$$.fragment),Y=p(),te=$("p"),te.innerHTML=ce,S=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=Kt(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=j(r,"P",{"data-svelte-h":!0}),T(b)!=="svelte-1m6p0sc"&&(b.innerHTML=Z),B=i(r),h(R.$$.fragment,r),C=i(r),X=j(r,"P",{"data-svelte-h":!0}),T(X)!=="svelte-trn9u8"&&(X.innerHTML=_),H=i(r),h(W.$$.fragment,r),k=i(r),G=j(r,"P",{"data-svelte-h":!0}),T(G)!=="svelte-17cxx5e"&&(G.innerHTML=o),U=i(r),h(E.$$.fragment,r),F=i(r),V=j(r,"P",{"data-svelte-h":!0}),T(V)!=="svelte-13cue08"&&(V.innerHTML=f),v=i(r),I=j(r,"P",{"data-svelte-h":!0}),T(I)!=="svelte-1l8einu"&&(I.innerHTML=me),N=i(r),h(z.$$.fragment,r),Y=i(r),te=j(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-xx7sn8"&&(te.innerHTML=ce),S=i(r),h(Q.$$.fragment,r),q=i(r),A=j(r,"P",{"data-svelte-h":!0}),T(A)!=="svelte-1lw9xm8"&&(A.textContent=se),fe=i(r),h(L.$$.fragment,r),P=i(r),D=j(r,"P",{"data-svelte-h":!0}),T(D)!=="svelte-1hrpv1v"&&(D.innerHTML=ae),ue=i(r),h(K.$$.fragment,r),O=i(r),ee=j(r,"P",{"data-svelte-h":!0}),T(ee)!=="svelte-2s71om"&&(ee.textContent=le)},m(r,w){y(s,r,w),l(r,m,w),y(t,r,w),l(r,c,w),l(r,b,w),l(r,B,w),y(R,r,w),l(r,C,w),l(r,X,w),l(r,H,w),y(W,r,w),l(r,k,w),l(r,G,w),l(r,U,w),y(E,r,w),l(r,F,w),l(r,V,w),l(r,v,w),l(r,I,w),l(r,N,w),y(z,r,w),l(r,Y,w),l(r,te,w),l(r,S,w),y(Q,r,w),l(r,q,w),l(r,A,w),l(r,fe,w),y(L,r,w),l(r,P,w),l(r,D,w),l(r,ue,w),y(K,r,w),l(r,O,w),l(r,ee,w),he=!0},p(r,w){const ye={};w&2&&(ye.$$scope={dirty:w,ctx:r}),s.$set(ye)},i(r){he||(M(s.$$.fragment,r),M(t.$$.fragment,r),M(R.$$.fragment,r),M(W.$$.fragment,r),M(E.$$.fragment,r),M(z.$$.fragment,r),M(Q.$$.fragment,r),M(L.$$.fragment,r),M(K.$$.fragment,r),he=!0)},o(r){d(s.$$.fragment,r),d(t.$$.fragment,r),d(R.$$.fragment,r),d(W.$$.fragment,r),d(E.$$.fragment,r),d(z.$$.fragment,r),d(Q.$$.fragment,r),d(L.$$.fragment,r),d(K.$$.fragment,r),he=!1},d(r){r&&(a(m),a(c),a(b),a(B),a(C),a(X),a(H),a(k),a(G),a(U),a(F),a(V),a(v),a(I),a(N),a(Y),a(te),a(S),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(W,r),g(E,r),g(z,r),g(Q,r),g(L,r),g(K,r)}}}function cs(J){let s,m;return s=new ze({props:{$$slots:{default:[ms]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function fs(J){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=j(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 us(J){let s,m="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",t,c,b,Z,B='Use the <a href="/docs/transformers/pr_29969/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,C,X,_,H="Decode the generated token ids back into text:",W,k,G;return c=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfb3B1c19ib29rc19tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpLmlucHV0X2lkcw==",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;username/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}}),C=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfb3B1c19ib29rc19tb2RlbCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoaW5wdXRzJTJDJTIwbWF4X25ld190b2tlbnMlM0Q0MCUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjB0b3BfayUzRDMwJTJDJTIwdG9wX3AlM0QwLjk1KQ==",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;username/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}}),k=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=B,R=p(),u(C.$$.fragment),X=p(),_=$("p"),_.textContent=H,W=p(),u(k.$$.fragment)},l(o){s=j(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-1c2y1ia"&&(s.innerHTML=m),t=i(o),h(c.$$.fragment,o),b=i(o),Z=j(o,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-14rr6kd"&&(Z.innerHTML=B),R=i(o),h(C.$$.fragment,o),X=i(o),_=j(o,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1918fu9"&&(_.textContent=H),W=i(o),h(k.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),y(c,o,U),l(o,b,U),l(o,Z,U),l(o,R,U),y(C,o,U),l(o,X,U),l(o,_,U),l(o,W,U),y(k,o,U),G=!0},p:ie,i(o){G||(M(c.$$.fragment,o),M(C.$$.fragment,o),M(k.$$.fragment,o),G=!0)},o(o){d(c.$$.fragment,o),d(C.$$.fragment,o),d(k.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(_),a(W)),g(c,o),g(C,o),g(k,o)}}}function hs(J){let s,m;return s=new ze({props:{$$slots:{default:[us]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ys(J){let s,m="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",t,c,b,Z,B='Use the <code>~transformers.generation_tf_utils.TFGenerationMixin.generate</code> 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,C,X,_,H="Decode the generated token ids back into text:",W,k,G;return c=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfb3B1c19ib29rc19tb2RlbCUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpLmlucHV0X2lkcw==",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;username/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}}),C=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxMlNlcUxNJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIydXNlcm5hbWUlMkZteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKGlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENDAlMkMlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTIwdG9wX2slM0QzMCUyQyUyMHRvcF9wJTNEMC45NSk=",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;username/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}}),k=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=B,R=p(),u(C.$$.fragment),X=p(),_=$("p"),_.textContent=H,W=p(),u(k.$$.fragment)},l(o){s=j(o,"P",{"data-svelte-h":!0}),T(s)!=="svelte-hw2mu6"&&(s.innerHTML=m),t=i(o),h(c.$$.fragment,o),b=i(o),Z=j(o,"P",{"data-svelte-h":!0}),T(Z)!=="svelte-yxyf4h"&&(Z.innerHTML=B),R=i(o),h(C.$$.fragment,o),X=i(o),_=j(o,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1918fu9"&&(_.textContent=H),W=i(o),h(k.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),y(c,o,U),l(o,b,U),l(o,Z,U),l(o,R,U),y(C,o,U),l(o,X,U),l(o,_,U),l(o,W,U),y(k,o,U),G=!0},p:ie,i(o){G||(M(c.$$.fragment,o),M(C.$$.fragment,o),M(k.$$.fragment,o),G=!0)},o(o){d(c.$$.fragment,o),d(C.$$.fragment,o),d(k.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(_),a(W)),g(c,o),g(C,o),g(k,o)}}}function Ms(J){let s,m;return s=new ze({props:{$$slots:{default:[ys]},$$scope:{ctx:J}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){y(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(M(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ds(J){let s,m,t,c,b,Z,B,R,C,X,_,H="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.",W,k,G="This guide will show you how to:",o,U,E='<li>Finetune <a href="https://huggingface.co/google-t5/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>',F,V,f,v,I="Before you begin, make sure you have all the necessary libraries installed:",me,N,z,Y,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,S,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/main/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,w,ye,Me,Ut="<code>translation</code>: an English and French translation of the text.",Se,de,Qe,ge,qe,be,kt="The next step is to load a T5 tokenizer to process the English-French language pairs:",Ae,$e,Le,je,_t="The preprocessing function you want to create needs to:",Pe,we,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>Set the target language (French) in the <code>text_target</code> parameter to ensure the tokenizer processes the target text correctly. If you don’t set <code>text_target</code>, the tokenizer processes the target text as English.</li> <li>Truncate sequences to be no longer than the maximum length set by the <code>max_length</code> parameter.</li>",De,Te,Ke,Ue,Zt='To apply the preprocessing function over the entire dataset, use 🤗 Datasets <a href="https://huggingface.co/docs/datasets/main/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:',Oe,ke,et,_e,Ct='Now create a batch of examples using <a href="/docs/transformers/pr_29969/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.',tt,ne,st,Je,at,Ze,vt='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):',lt,Ce,nt,ve,xt='Then create a function that passes your predictions and labels to <a href="https://huggingface.co/docs/evaluate/main/en/package_reference/main_classes#evaluate.EvaluationModule.compute" rel="nofollow">compute</a> to calculate the SacreBLEU score:',rt,xe,ot,Re,Rt="Your <code>compute_metrics</code> function is ready to go now, and you’ll return to it when you setup your training.",pt,Xe,it,re,mt,oe,ct,We,ft,Ge,Xt="Great, now that you’ve finetuned a model, you can use it for inference!",ut,Be,Wt="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:",ht,Ve,yt,Fe,Gt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_29969/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for translation with your model, and pass your text to it:',Mt,He,dt,Ee,Bt="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",gt,pe,bt,Ie,$t,Ye,jt;return b=new Ne({props:{title:"Translation",local:"translation",headingTag:"h1"}}),B=new Ot({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"}]}}),C=new Yt({props:{id:"1JvfrvZgi6c"}}),V=new wt({props:{$$slots:{default:[ts]},$$scope:{ctx:J}}}),N=new x({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyUyMGRhdGFzZXRzJTIwZXZhbHVhdGUlMjBzYWNyZWJsZXU=",highlighted:"pip install transformers datasets evaluate sacrebleu",wrap:!1}}),S=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}}),w=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}}),de=new Ne({props:{title:"Preprocess",local:"preprocess",headingTag:"h2"}}),ge=new Yt({props:{id:"XAR8jnZZuUs"}}),$e=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZ29vZ2xlLXQ1JTJGdDUtc21hbGwlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KQ==",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;google-t5/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}}),ke=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 Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ns],pytorch:[as]},$$scope:{ctx:J}}}),Je=new Ne({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),Ce=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}}),Xe=new Ne({props:{title:"Train",local:"train",headingTag:"h2"}}),re=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[cs],pytorch:[ps]},$$scope:{ctx:J}}}),oe=new wt({props:{$$slots:{default:[fs]},$$scope:{ctx:J}}}),We=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}}),He=new x({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdHJhbnNsYXRvciUyMCUzRCUyMHBpcGVsaW5lKCUyMnRyYW5zbGF0aW9uX3h4X3RvX3l5JTIyJTJDJTIwbW9kZWwlM0QlMjJ1c2VybmFtZSUyRm15X2F3ZXNvbWVfb3B1c19ib29rc19tb2RlbCUyMiklMEF0cmFuc2xhdG9yKHRleHQp",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-comment"># Change \`xx\` to the language of the input and \`yy\` to the language of the desired output.</span>
<span class="hljs-comment"># Examples: &quot;en&quot; for English, &quot;fr&quot; for French, &quot;de&quot; for German, &quot;es&quot; for Spanish, &quot;zh&quot; for Chinese, etc; translation_en_to_fr translates English to French</span>
<span class="hljs-comment"># You can view all the lists of languages here - https://huggingface.co/languages</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>translator = pipeline(<span class="hljs-string">&quot;translation_xx_to_yy&quot;</span>, model=<span class="hljs-string">&quot;username/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 Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ms],pytorch:[hs]},$$scope:{ctx:J}}}),Ie=new es({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/tasks/translation.md"}}),{c(){s=$("meta"),m=p(),t=$("p"),c=p(),u(b.$$.fragment),Z=p(),u(B.$$.fragment),R=p(),u(C.$$.fragment),X=p(),_=$("p"),_.textContent=H,W=p(),k=$("p"),k.textContent=G,o=p(),U=$("ol"),U.innerHTML=E,F=p(),u(V.$$.fragment),f=p(),v=$("p"),v.textContent=I,me=p(),u(N.$$.fragment),z=p(),Y=$("p"),Y.textContent=te,ce=p(),u(S.$$.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(w.$$.fragment),ye=p(),Me=$("p"),Me.innerHTML=Ut,Se=p(),u(de.$$.fragment),Qe=p(),u(ge.$$.fragment),qe=p(),be=$("p"),be.textContent=kt,Ae=p(),u($e.$$.fragment),Le=p(),je=$("p"),je.textContent=_t,Pe=p(),we=$("ol"),we.innerHTML=Jt,De=p(),u(Te.$$.fragment),Ke=p(),Ue=$("p"),Ue.innerHTML=Zt,Oe=p(),u(ke.$$.fragment),et=p(),_e=$("p"),_e.innerHTML=Ct,tt=p(),u(ne.$$.fragment),st=p(),u(Je.$$.fragment),at=p(),Ze=$("p"),Ze.innerHTML=vt,lt=p(),u(Ce.$$.fragment),nt=p(),ve=$("p"),ve.innerHTML=xt,rt=p(),u(xe.$$.fragment),ot=p(),Re=$("p"),Re.innerHTML=Rt,pt=p(),u(Xe.$$.fragment),it=p(),u(re.$$.fragment),mt=p(),u(oe.$$.fragment),ct=p(),u(We.$$.fragment),ft=p(),Ge=$("p"),Ge.textContent=Xt,ut=p(),Be=$("p"),Be.textContent=Wt,ht=p(),u(Ve.$$.fragment),yt=p(),Fe=$("p"),Fe.innerHTML=Gt,Mt=p(),u(He.$$.fragment),dt=p(),Ee=$("p"),Ee.innerHTML=Bt,gt=p(),u(pe.$$.fragment),bt=p(),u(Ie.$$.fragment),$t=p(),Ye=$("p"),this.h()},l(e){const n=Lt("svelte-u9bgzb",document.head);s=j(n,"META",{name:!0,content:!0}),n.forEach(a),m=i(e),t=j(e,"P",{}),Nt(t).forEach(a),c=i(e),h(b.$$.fragment,e),Z=i(e),h(B.$$.fragment,e),R=i(e),h(C.$$.fragment,e),X=i(e),_=j(e,"P",{"data-svelte-h":!0}),T(_)!=="svelte-x8f5ei"&&(_.textContent=H),W=i(e),k=j(e,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1aff4p7"&&(k.textContent=G),o=i(e),U=j(e,"OL",{"data-svelte-h":!0}),T(U)!=="svelte-1hirfhi"&&(U.innerHTML=E),F=i(e),h(V.$$.fragment,e),f=i(e),v=j(e,"P",{"data-svelte-h":!0}),T(v)!=="svelte-1c9nexd"&&(v.textContent=I),me=i(e),h(N.$$.fragment,e),z=i(e),Y=j(e,"P",{"data-svelte-h":!0}),T(Y)!=="svelte-k76o1m"&&(Y.textContent=te),ce=i(e),h(S.$$.fragment,e),Q=i(e),h(q.$$.fragment,e),A=i(e),se=j(e,"P",{"data-svelte-h":!0}),T(se)!=="svelte-1r4htuf"&&(se.innerHTML=fe),L=i(e),h(P.$$.fragment,e),D=i(e),ae=j(e,"P",{"data-svelte-h":!0}),T(ae)!=="svelte-11qrtib"&&(ae.innerHTML=ue),K=i(e),h(O.$$.fragment,e),ee=i(e),le=j(e,"P",{"data-svelte-h":!0}),T(le)!=="svelte-1m91ua0"&&(le.textContent=he),r=i(e),h(w.$$.fragment,e),ye=i(e),Me=j(e,"P",{"data-svelte-h":!0}),T(Me)!=="svelte-pj869u"&&(Me.innerHTML=Ut),Se=i(e),h(de.$$.fragment,e),Qe=i(e),h(ge.$$.fragment,e),qe=i(e),be=j(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-1m3bu0h"&&(be.textContent=kt),Ae=i(e),h($e.$$.fragment,e),Le=i(e),je=j(e,"P",{"data-svelte-h":!0}),T(je)!=="svelte-pduvot"&&(je.textContent=_t),Pe=i(e),we=j(e,"OL",{"data-svelte-h":!0}),T(we)!=="svelte-1q1yj0j"&&(we.innerHTML=Jt),De=i(e),h(Te.$$.fragment,e),Ke=i(e),Ue=j(e,"P",{"data-svelte-h":!0}),T(Ue)!=="svelte-74644w"&&(Ue.innerHTML=Zt),Oe=i(e),h(ke.$$.fragment,e),et=i(e),_e=j(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-1br142i"&&(_e.innerHTML=Ct),tt=i(e),h(ne.$$.fragment,e),st=i(e),h(Je.$$.fragment,e),at=i(e),Ze=j(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1mb37bt"&&(Ze.innerHTML=vt),lt=i(e),h(Ce.$$.fragment,e),nt=i(e),ve=j(e,"P",{"data-svelte-h":!0}),T(ve)!=="svelte-6baa48"&&(ve.innerHTML=xt),rt=i(e),h(xe.$$.fragment,e),ot=i(e),Re=j(e,"P",{"data-svelte-h":!0}),T(Re)!=="svelte-183aynn"&&(Re.innerHTML=Rt),pt=i(e),h(Xe.$$.fragment,e),it=i(e),h(re.$$.fragment,e),mt=i(e),h(oe.$$.fragment,e),ct=i(e),h(We.$$.fragment,e),ft=i(e),Ge=j(e,"P",{"data-svelte-h":!0}),T(Ge)!=="svelte-633ppb"&&(Ge.textContent=Xt),ut=i(e),Be=j(e,"P",{"data-svelte-h":!0}),T(Be)!=="svelte-1js4i9r"&&(Be.textContent=Wt),ht=i(e),h(Ve.$$.fragment,e),yt=i(e),Fe=j(e,"P",{"data-svelte-h":!0}),T(Fe)!=="svelte-3shgus"&&(Fe.innerHTML=Gt),Mt=i(e),h(He.$$.fragment,e),dt=i(e),Ee=j(e,"P",{"data-svelte-h":!0}),T(Ee)!=="svelte-1njl8vm"&&(Ee.innerHTML=Bt),gt=i(e),h(pe.$$.fragment,e),bt=i(e),h(Ie.$$.fragment,e),$t=i(e),Ye=j(e,"P",{}),Nt(Ye).forEach(a),this.h()},h(){zt(s,"name","hf:doc:metadata"),zt(s,"content",gs)},m(e,n){Pt(document.head,s),l(e,m,n),l(e,t,n),l(e,c,n),y(b,e,n),l(e,Z,n),y(B,e,n),l(e,R,n),y(C,e,n),l(e,X,n),l(e,_,n),l(e,W,n),l(e,k,n),l(e,o,n),l(e,U,n),l(e,F,n),y(V,e,n),l(e,f,n),l(e,v,n),l(e,me,n),y(N,e,n),l(e,z,n),l(e,Y,n),l(e,ce,n),y(S,e,n),l(e,Q,n),y(q,e,n),l(e,A,n),l(e,se,n),l(e,L,n),y(P,e,n),l(e,D,n),l(e,ae,n),l(e,K,n),y(O,e,n),l(e,ee,n),l(e,le,n),l(e,r,n),y(w,e,n),l(e,ye,n),l(e,Me,n),l(e,Se,n),y(de,e,n),l(e,Qe,n),y(ge,e,n),l(e,qe,n),l(e,be,n),l(e,Ae,n),y($e,e,n),l(e,Le,n),l(e,je,n),l(e,Pe,n),l(e,we,n),l(e,De,n),y(Te,e,n),l(e,Ke,n),l(e,Ue,n),l(e,Oe,n),y(ke,e,n),l(e,et,n),l(e,_e,n),l(e,tt,n),y(ne,e,n),l(e,st,n),y(Je,e,n),l(e,at,n),l(e,Ze,n),l(e,lt,n),y(Ce,e,n),l(e,nt,n),l(e,ve,n),l(e,rt,n),y(xe,e,n),l(e,ot,n),l(e,Re,n),l(e,pt,n),y(Xe,e,n),l(e,it,n),y(re,e,n),l(e,mt,n),y(oe,e,n),l(e,ct,n),y(We,e,n),l(e,ft,n),l(e,Ge,n),l(e,ut,n),l(e,Be,n),l(e,ht,n),y(Ve,e,n),l(e,yt,n),l(e,Fe,n),l(e,Mt,n),y(He,e,n),l(e,dt,n),l(e,Ee,n),l(e,gt,n),y(pe,e,n),l(e,bt,n),y(Ie,e,n),l(e,$t,n),l(e,Ye,n),jt=!0},p(e,[n]){const Vt={};n&2&&(Vt.$$scope={dirty:n,ctx:e}),V.$set(Vt);const Ft={};n&2&&(Ft.$$scope={dirty:n,ctx:e}),ne.$set(Ft);const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),re.$set(Ht);const Et={};n&2&&(Et.$$scope={dirty:n,ctx:e}),oe.$set(Et);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),pe.$set(It)},i(e){jt||(M(b.$$.fragment,e),M(B.$$.fragment,e),M(C.$$.fragment,e),M(V.$$.fragment,e),M(N.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(P.$$.fragment,e),M(O.$$.fragment,e),M(w.$$.fragment,e),M(de.$$.fragment,e),M(ge.$$.fragment,e),M($e.$$.fragment,e),M(Te.$$.fragment,e),M(ke.$$.fragment,e),M(ne.$$.fragment,e),M(Je.$$.fragment,e),M(Ce.$$.fragment,e),M(xe.$$.fragment,e),M(Xe.$$.fragment,e),M(re.$$.fragment,e),M(oe.$$.fragment,e),M(We.$$.fragment,e),M(Ve.$$.fragment,e),M(He.$$.fragment,e),M(pe.$$.fragment,e),M(Ie.$$.fragment,e),jt=!0)},o(e){d(b.$$.fragment,e),d(B.$$.fragment,e),d(C.$$.fragment,e),d(V.$$.fragment,e),d(N.$$.fragment,e),d(S.$$.fragment,e),d(q.$$.fragment,e),d(P.$$.fragment,e),d(O.$$.fragment,e),d(w.$$.fragment,e),d(de.$$.fragment,e),d(ge.$$.fragment,e),d($e.$$.fragment,e),d(Te.$$.fragment,e),d(ke.$$.fragment,e),d(ne.$$.fragment,e),d(Je.$$.fragment,e),d(Ce.$$.fragment,e),d(xe.$$.fragment,e),d(Xe.$$.fragment,e),d(re.$$.fragment,e),d(oe.$$.fragment,e),d(We.$$.fragment,e),d(Ve.$$.fragment,e),d(He.$$.fragment,e),d(pe.$$.fragment,e),d(Ie.$$.fragment,e),jt=!1},d(e){e&&(a(m),a(t),a(c),a(Z),a(R),a(X),a(_),a(W),a(k),a(o),a(U),a(F),a(f),a(v),a(me),a(z),a(Y),a(ce),a(Q),a(A),a(se),a(L),a(D),a(ae),a(K),a(ee),a(le),a(r),a(ye),a(Me),a(Se),a(Qe),a(qe),a(be),a(Ae),a(Le),a(je),a(Pe),a(we),a(De),a(Ke),a(Ue),a(Oe),a(et),a(_e),a(tt),a(st),a(at),a(Ze),a(lt),a(nt),a(ve),a(rt),a(ot),a(Re),a(pt),a(it),a(mt),a(ct),a(ft),a(Ge),a(ut),a(Be),a(ht),a(yt),a(Fe),a(Mt),a(dt),a(Ee),a(gt),a(bt),a($t),a(Ye)),a(s),g(b,e),g(B,e),g(C,e),g(V,e),g(N,e),g(S,e),g(q,e),g(P,e),g(O,e),g(w,e),g(de,e),g(ge,e),g($e,e),g(Te,e),g(ke,e),g(ne,e),g(Je,e),g(Ce,e),g(xe,e),g(Xe,e),g(re,e),g(oe,e),g(We,e),g(Ve,e),g(He,e),g(pe,e),g(Ie,e)}}}const gs='{"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 bs(J){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zs extends qt{constructor(s){super(),At(this,s,bs,ds,St,{})}}export{Zs as component};
