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 w,f as a,c as i,j as zt,u as h,x as T,k as Nt,y as Pt,a as l,v as y,d,t as M,w as g,m as Dt,n as Kt}from"../chunks/index.d9030fc9.js";import{T as jt}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 Ne}from"../chunks/Markdown.7217f838.js";import{H as ze,E as es}from"../chunks/EditOnGithub.91d95064.js";function ts(U){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=w(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(U){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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function as(U){let s,m;return s=new Ne({props:{$$slots:{default:[ss]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ls(U){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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ns(U){let s,m;return s=new Ne({props:{$$slots:{default:[ls]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function rs(U){let s,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/pr_31098/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-hsi2iv"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function os(U){let s,m,t,c='You’re ready to start training your model now! Load T5 with <a href="/docs/transformers/pr_31098/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a>:',b,Z,V,R,v="At this point, only three steps remain:",X,_,I='<li>Define your training hyperparameters in <a href="/docs/transformers/pr_31098/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_31098/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_31098/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_31098/en/main_classes/trainer#transformers.Trainer.train">train()</a> to finetune your model.</li>',G,k,W,o,J='Once training is completed, share your model to the Hub with the <a href="/docs/transformers/pr_31098/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',F,H,B;return s=new jt({props:{$$slots:{default:[rs]},$$scope:{ctx:U}}}),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:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIybXlfYXdlc29tZV9vcHVzX2Jvb2tzX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rfd2l0aF9nZW5lcmF0ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHB1c2hfdG9faHViJTNEVHJ1ZSUyQyUwQSklMEElMEF0cmFpbmVyJTIwJTNEJTIwU2VxMlNlcVRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHRva2VuaXplZF9ib29rcyU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX2Jvb2tzJTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSUyMCUyMCUyMCUyMGRhdGFfY29sbGF0b3IlM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwY29tcHV0ZV9tZXRyaWNzJTNEY29tcHV0ZV9tZXRyaWNzJTJDJTBBKSUwQSUwQXRyYWluZXIudHJhaW4oKQ==",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-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),V=p(),R=$("p"),R.textContent=v,X=p(),_=$("ol"),_.innerHTML=I,G=p(),u(k.$$.fragment),W=p(),o=$("p"),o.innerHTML=J,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-mz88dq"&&(t.innerHTML=c),b=i(f),h(Z.$$.fragment,f),V=i(f),R=w(f,"P",{"data-svelte-h":!0}),T(R)!=="svelte-l42k0i"&&(R.textContent=v),X=i(f),_=w(f,"OL",{"data-svelte-h":!0}),T(_)!=="svelte-g4kp8s"&&(_.innerHTML=I),G=i(f),h(k.$$.fragment,f),W=i(f),o=w(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-1j5t4ch"&&(o.innerHTML=J),F=i(f),h(H.$$.fragment,f)},m(f,C){y(s,f,C),l(f,m,C),l(f,t,C),l(f,b,C),y(Z,f,C),l(f,V,C),l(f,R,C),l(f,X,C),l(f,_,C),l(f,G,C),y(k,f,C),l(f,W,C),l(f,o,C),l(f,F,C),y(H,f,C),B=!0},p(f,C){const E={};C&2&&(E.$$scope={dirty:C,ctx:f}),s.$set(E)},i(f){B||(d(s.$$.fragment,f),d(Z.$$.fragment,f),d(k.$$.fragment,f),d(H.$$.fragment,f),B=!0)},o(f){M(s.$$.fragment,f),M(Z.$$.fragment,f),M(k.$$.fragment,f),M(H.$$.fragment,f),B=!1},d(f){f&&(a(m),a(t),a(b),a(V),a(R),a(X),a(_),a(G),a(W),a(o),a(F)),g(s,f),g(Z,f),g(k,f),g(H,f)}}}function ps(U){let s,m;return s=new Ne({props:{$$slots:{default:[os]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function is(U){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 ms(U){let s,m,t,c,b,Z='Then you can load T5 with <a href="/docs/transformers/pr_31098/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a>:',V,R,v,X,_='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/pr_31098/en/main_classes/model#transformers.TFPreTrainedModel.prepare_tf_dataset">prepare_tf_dataset()</a>:',I,G,k,W,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:',J,F,H,B,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,E,me='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/pr_31098/en/main_classes/keras_callbacks#transformers.KerasMetricCallback">KerasMetricCallback</a>:',z,N,Y,te,ce='Specify where to push your model and tokenizer in the <a href="/docs/transformers/pr_31098/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 jt({props:{$$slots:{default:[is]},$$scope:{ctx:U}}}),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}}),G=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}}),N=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,V=p(),u(R.$$.fragment),v=p(),X=$("p"),X.innerHTML=_,I=p(),u(G.$$.fragment),k=p(),W=$("p"),W.innerHTML=o,J=p(),u(F.$$.fragment),H=p(),B=$("p"),B.innerHTML=f,C=p(),E=$("p"),E.innerHTML=me,z=p(),u(N.$$.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=w(r,"P",{"data-svelte-h":!0}),T(b)!=="svelte-1ig96kw"&&(b.innerHTML=Z),V=i(r),h(R.$$.fragment,r),v=i(r),X=w(r,"P",{"data-svelte-h":!0}),T(X)!=="svelte-vfywpk"&&(X.innerHTML=_),I=i(r),h(G.$$.fragment,r),k=i(r),W=w(r,"P",{"data-svelte-h":!0}),T(W)!=="svelte-17cxx5e"&&(W.innerHTML=o),J=i(r),h(F.$$.fragment,r),H=i(r),B=w(r,"P",{"data-svelte-h":!0}),T(B)!=="svelte-13cue08"&&(B.innerHTML=f),C=i(r),E=w(r,"P",{"data-svelte-h":!0}),T(E)!=="svelte-1p2uyxu"&&(E.innerHTML=me),z=i(r),h(N.$$.fragment,r),Y=i(r),te=w(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-2hwiic"&&(te.innerHTML=ce),S=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){y(s,r,j),l(r,m,j),y(t,r,j),l(r,c,j),l(r,b,j),l(r,V,j),y(R,r,j),l(r,v,j),l(r,X,j),l(r,I,j),y(G,r,j),l(r,k,j),l(r,W,j),l(r,J,j),y(F,r,j),l(r,H,j),l(r,B,j),l(r,C,j),l(r,E,j),l(r,z,j),y(N,r,j),l(r,Y,j),l(r,te,j),l(r,S,j),y(Q,r,j),l(r,q,j),l(r,A,j),l(r,fe,j),y(L,r,j),l(r,P,j),l(r,D,j),l(r,ue,j),y(K,r,j),l(r,O,j),l(r,ee,j),he=!0},p(r,j){const ye={};j&2&&(ye.$$scope={dirty:j,ctx:r}),s.$set(ye)},i(r){he||(d(s.$$.fragment,r),d(t.$$.fragment,r),d(R.$$.fragment,r),d(G.$$.fragment,r),d(F.$$.fragment,r),d(N.$$.fragment,r),d(Q.$$.fragment,r),d(L.$$.fragment,r),d(K.$$.fragment,r),he=!0)},o(r){M(s.$$.fragment,r),M(t.$$.fragment,r),M(R.$$.fragment,r),M(G.$$.fragment,r),M(F.$$.fragment,r),M(N.$$.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(V),a(v),a(X),a(I),a(k),a(W),a(J),a(H),a(B),a(C),a(E),a(z),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(G,r),g(F,r),g(N,r),g(Q,r),g(L,r),g(K,r)}}}function cs(U){let s,m;return s=new Ne({props:{$$slots:{default:[ms]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function fs(U){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 us(U){let s,m="Tokenize the text and return the <code>input_ids</code> as PyTorch tensors:",t,c,b,Z,V='Use the <a href="/docs/transformers/pr_31098/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,X,_,I="Decode the generated token ids back into text:",G,k,W;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}}),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=V,R=p(),u(v.$$.fragment),X=p(),_=$("p"),_.textContent=I,G=p(),u(k.$$.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-1x3jr9h"&&(Z.innerHTML=V),R=i(o),h(v.$$.fragment,o),X=i(o),_=w(o,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1918fu9"&&(_.textContent=I),G=i(o),h(k.$$.fragment,o)},m(o,J){l(o,s,J),l(o,t,J),y(c,o,J),l(o,b,J),l(o,Z,J),l(o,R,J),y(v,o,J),l(o,X,J),l(o,_,J),l(o,G,J),y(k,o,J),W=!0},p:ie,i(o){W||(d(c.$$.fragment,o),d(v.$$.fragment,o),d(k.$$.fragment,o),W=!0)},o(o){M(c.$$.fragment,o),M(v.$$.fragment,o),M(k.$$.fragment,o),W=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(_),a(G)),g(c,o),g(v,o),g(k,o)}}}function hs(U){let s,m;return s=new Ne({props:{$$slots:{default:[us]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ys(U){let s,m="Tokenize the text and return the <code>input_ids</code> as TensorFlow tensors:",t,c,b,Z,V='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,v,X,_,I="Decode the generated token ids back into text:",G,k,W;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}}),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=V,R=p(),u(v.$$.fragment),X=p(),_=$("p"),_.textContent=I,G=p(),u(k.$$.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-yxyf4h"&&(Z.innerHTML=V),R=i(o),h(v.$$.fragment,o),X=i(o),_=w(o,"P",{"data-svelte-h":!0}),T(_)!=="svelte-1918fu9"&&(_.textContent=I),G=i(o),h(k.$$.fragment,o)},m(o,J){l(o,s,J),l(o,t,J),y(c,o,J),l(o,b,J),l(o,Z,J),l(o,R,J),y(v,o,J),l(o,X,J),l(o,_,J),l(o,G,J),y(k,o,J),W=!0},p:ie,i(o){W||(d(c.$$.fragment,o),d(v.$$.fragment,o),d(k.$$.fragment,o),W=!0)},o(o){M(c.$$.fragment,o),M(v.$$.fragment,o),M(k.$$.fragment,o),W=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(_),a(G)),g(c,o),g(v,o),g(k,o)}}}function ds(U){let s,m;return s=new Ne({props:{$$slots:{default:[ys]},$$scope:{ctx:U}}}),{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||(d(s.$$.fragment,t),m=!0)},o(t){M(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function Ms(U){let s,m,t,c,b,Z,V,R,v,X,_,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.",G,k,W="This guide will show you how to:",o,J,F='<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>',H,B,f,C,E="Before you begin, make sure you have all the necessary libraries installed:",me,z,N,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,j,ye,de,Jt="<code>translation</code>: an English and French translation of the text.",Se,Me,Qe,ge,qe,be,kt="The next step is to load a T5 tokenizer to process the English-French language pairs:",Ae,$e,Le,we,_t="The preprocessing function you want to create needs to:",Pe,je,Ut="<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,Je,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,vt='Now create a batch of examples using <a href="/docs/transformers/pr_31098/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,Ue,at,Ze,Ct='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,ve,nt,Ce,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,Ge,ft,We,Xt="Great, now that you’ve finetuned a model, you can use it for inference!",ut,Ve,Gt="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,Be,yt,He,Wt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/pr_31098/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,Mt,Fe,Vt="You can also manually replicate the results of the <code>pipeline</code> if you’d like:",gt,pe,bt,Ee,$t,Ye,wt;return b=new ze({props:{title:"Translation",local:"translation",headingTag:"h1"}}),V=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"}]}}),v=new Yt({props:{id:"1JvfrvZgi6c"}}),B=new jt({props:{$$slots:{default:[ts]},$$scope:{ctx:U}}}),z=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 ze({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 ze({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:U}}}),Ue=new ze({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}}),Xe=new ze({props:{title:"Train",local:"train",headingTag:"h2"}}),re=new Tt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[cs],pytorch:[ps]},$$scope:{ctx:U}}}),oe=new jt({props:{$$slots:{default:[fs]},$$scope:{ctx:U}}}),Ge=new ze({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Be=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:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdHJhbnNsYXRvciUyMCUzRCUyMHBpcGVsaW5lKCUyMnRyYW5zbGF0aW9uX3h4X3RvX3l5JTIyJTJDJTIwbW9kZWwlM0QlMjJteV9hd2Vzb21lX29wdXNfYm9va3NfbW9kZWwlMjIpJTBBdHJhbnNsYXRvcih0ZXh0KQ==",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;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:[ds],pytorch:[hs]},$$scope:{ctx:U}}}),Ee=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(V.$$.fragment),R=p(),u(v.$$.fragment),X=p(),_=$("p"),_.textContent=I,G=p(),k=$("p"),k.textContent=W,o=p(),J=$("ol"),J.innerHTML=F,H=p(),u(B.$$.fragment),f=p(),C=$("p"),C.textContent=E,me=p(),u(z.$$.fragment),N=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(j.$$.fragment),ye=p(),de=$("p"),de.innerHTML=Jt,Se=p(),u(Me.$$.fragment),Qe=p(),u(ge.$$.fragment),qe=p(),be=$("p"),be.textContent=kt,Ae=p(),u($e.$$.fragment),Le=p(),we=$("p"),we.textContent=_t,Pe=p(),je=$("ol"),je.innerHTML=Ut,De=p(),u(Te.$$.fragment),Ke=p(),Je=$("p"),Je.innerHTML=Zt,Oe=p(),u(ke.$$.fragment),et=p(),_e=$("p"),_e.innerHTML=vt,tt=p(),u(ne.$$.fragment),st=p(),u(Ue.$$.fragment),at=p(),Ze=$("p"),Ze.innerHTML=Ct,lt=p(),u(ve.$$.fragment),nt=p(),Ce=$("p"),Ce.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(Ge.$$.fragment),ft=p(),We=$("p"),We.textContent=Xt,ut=p(),Ve=$("p"),Ve.textContent=Gt,ht=p(),u(Be.$$.fragment),yt=p(),He=$("p"),He.innerHTML=Wt,dt=p(),u(Ie.$$.fragment),Mt=p(),Fe=$("p"),Fe.innerHTML=Vt,gt=p(),u(pe.$$.fragment),bt=p(),u(Ee.$$.fragment),$t=p(),Ye=$("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",{}),zt(t).forEach(a),c=i(e),h(b.$$.fragment,e),Z=i(e),h(V.$$.fragment,e),R=i(e),h(v.$$.fragment,e),X=i(e),_=w(e,"P",{"data-svelte-h":!0}),T(_)!=="svelte-x8f5ei"&&(_.textContent=I),G=i(e),k=w(e,"P",{"data-svelte-h":!0}),T(k)!=="svelte-1aff4p7"&&(k.textContent=W),o=i(e),J=w(e,"OL",{"data-svelte-h":!0}),T(J)!=="svelte-1hirfhi"&&(J.innerHTML=F),H=i(e),h(B.$$.fragment,e),f=i(e),C=w(e,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1c9nexd"&&(C.textContent=E),me=i(e),h(z.$$.fragment,e),N=i(e),Y=w(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=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-11qrtib"&&(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),ye=i(e),de=w(e,"P",{"data-svelte-h":!0}),T(de)!=="svelte-pj869u"&&(de.innerHTML=Jt),Se=i(e),h(Me.$$.fragment,e),Qe=i(e),h(ge.$$.fragment,e),qe=i(e),be=w(e,"P",{"data-svelte-h":!0}),T(be)!=="svelte-1m3bu0h"&&(be.textContent=kt),Ae=i(e),h($e.$$.fragment,e),Le=i(e),we=w(e,"P",{"data-svelte-h":!0}),T(we)!=="svelte-pduvot"&&(we.textContent=_t),Pe=i(e),je=w(e,"OL",{"data-svelte-h":!0}),T(je)!=="svelte-1q1yj0j"&&(je.innerHTML=Ut),De=i(e),h(Te.$$.fragment,e),Ke=i(e),Je=w(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-74644w"&&(Je.innerHTML=Zt),Oe=i(e),h(ke.$$.fragment,e),et=i(e),_e=w(e,"P",{"data-svelte-h":!0}),T(_e)!=="svelte-bku4ma"&&(_e.innerHTML=vt),tt=i(e),h(ne.$$.fragment,e),st=i(e),h(Ue.$$.fragment,e),at=i(e),Ze=w(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1mb37bt"&&(Ze.innerHTML=Ct),lt=i(e),h(ve.$$.fragment,e),nt=i(e),Ce=w(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-6baa48"&&(Ce.innerHTML=xt),rt=i(e),h(xe.$$.fragment,e),ot=i(e),Re=w(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(Ge.$$.fragment,e),ft=i(e),We=w(e,"P",{"data-svelte-h":!0}),T(We)!=="svelte-633ppb"&&(We.textContent=Xt),ut=i(e),Ve=w(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-1js4i9r"&&(Ve.textContent=Gt),ht=i(e),h(Be.$$.fragment,e),yt=i(e),He=w(e,"P",{"data-svelte-h":!0}),T(He)!=="svelte-zdd2uw"&&(He.innerHTML=Wt),dt=i(e),h(Ie.$$.fragment,e),Mt=i(e),Fe=w(e,"P",{"data-svelte-h":!0}),T(Fe)!=="svelte-1njl8vm"&&(Fe.innerHTML=Vt),gt=i(e),h(pe.$$.fragment,e),bt=i(e),h(Ee.$$.fragment,e),$t=i(e),Ye=w(e,"P",{}),zt(Ye).forEach(a),this.h()},h(){Nt(s,"name","hf:doc:metadata"),Nt(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(V,e,n),l(e,R,n),y(v,e,n),l(e,X,n),l(e,_,n),l(e,G,n),l(e,k,n),l(e,o,n),l(e,J,n),l(e,H,n),y(B,e,n),l(e,f,n),l(e,C,n),l(e,me,n),y(z,e,n),l(e,N,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(j,e,n),l(e,ye,n),l(e,de,n),l(e,Se,n),y(Me,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,we,n),l(e,Pe,n),l(e,je,n),l(e,De,n),y(Te,e,n),l(e,Ke,n),l(e,Je,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(Ue,e,n),l(e,at,n),l(e,Ze,n),l(e,lt,n),y(ve,e,n),l(e,nt,n),l(e,Ce,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(Ge,e,n),l(e,ft,n),l(e,We,n),l(e,ut,n),l(e,Ve,n),l(e,ht,n),y(Be,e,n),l(e,yt,n),l(e,He,n),l(e,dt,n),y(Ie,e,n),l(e,Mt,n),l(e,Fe,n),l(e,gt,n),y(pe,e,n),l(e,bt,n),y(Ee,e,n),l(e,$t,n),l(e,Ye,n),wt=!0},p(e,[n]){const Bt={};n&2&&(Bt.$$scope={dirty:n,ctx:e}),B.$set(Bt);const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),ne.$set(Ht);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),re.$set(It);const Ft={};n&2&&(Ft.$$scope={dirty:n,ctx:e}),oe.$set(Ft);const Et={};n&2&&(Et.$$scope={dirty:n,ctx:e}),pe.$set(Et)},i(e){wt||(d(b.$$.fragment,e),d(V.$$.fragment,e),d(v.$$.fragment,e),d(B.$$.fragment,e),d(z.$$.fragment,e),d(S.$$.fragment,e),d(q.$$.fragment,e),d(P.$$.fragment,e),d(O.$$.fragment,e),d(j.$$.fragment,e),d(Me.$$.fragment,e),d(ge.$$.fragment,e),d($e.$$.fragment,e),d(Te.$$.fragment,e),d(ke.$$.fragment,e),d(ne.$$.fragment,e),d(Ue.$$.fragment,e),d(ve.$$.fragment,e),d(xe.$$.fragment,e),d(Xe.$$.fragment,e),d(re.$$.fragment,e),d(oe.$$.fragment,e),d(Ge.$$.fragment,e),d(Be.$$.fragment,e),d(Ie.$$.fragment,e),d(pe.$$.fragment,e),d(Ee.$$.fragment,e),wt=!0)},o(e){M(b.$$.fragment,e),M(V.$$.fragment,e),M(v.$$.fragment,e),M(B.$$.fragment,e),M(z.$$.fragment,e),M(S.$$.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(ke.$$.fragment,e),M(ne.$$.fragment,e),M(Ue.$$.fragment,e),M(ve.$$.fragment,e),M(xe.$$.fragment,e),M(Xe.$$.fragment,e),M(re.$$.fragment,e),M(oe.$$.fragment,e),M(Ge.$$.fragment,e),M(Be.$$.fragment,e),M(Ie.$$.fragment,e),M(pe.$$.fragment,e),M(Ee.$$.fragment,e),wt=!1},d(e){e&&(a(m),a(t),a(c),a(Z),a(R),a(X),a(_),a(G),a(k),a(o),a(J),a(H),a(f),a(C),a(me),a(N),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(de),a(Se),a(Qe),a(qe),a(be),a(Ae),a(Le),a(we),a(Pe),a(je),a(De),a(Ke),a(Je),a(Oe),a(et),a(_e),a(tt),a(st),a(at),a(Ze),a(lt),a(nt),a(Ce),a(rt),a(ot),a(Re),a(pt),a(it),a(mt),a(ct),a(ft),a(We),a(ut),a(Ve),a(ht),a(yt),a(He),a(dt),a(Mt),a(Fe),a(gt),a(bt),a($t),a(Ye)),a(s),g(b,e),g(V,e),g(v,e),g(B,e),g(z,e),g(S,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(ke,e),g(ne,e),g(Ue,e),g(ve,e),g(xe,e),g(Xe,e),g(re,e),g(oe,e),g(Ge,e),g(Be,e),g(Ie,e),g(pe,e),g(Ee,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(U){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zs extends qt{constructor(s){super(),At(this,s,bs,Ms,St,{})}}export{Zs as component};
