import{s as St,o as Qt,n as ie}from"../chunks/scheduler.18a86fab.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 M,d as y,t as d,w as g,m as Dt,n as Kt}from"../chunks/index.98837b22.js";import{T as wt}from"../chunks/Tip.77304350.js";import{Y as Yt}from"../chunks/Youtube.14fb207c.js";import{C as x}from"../chunks/CodeBlock.8d0c2e8a.js";import{D as Ot}from"../chunks/DocNotebookDropdown.a04a6b2a.js";import{F as Tt,M as ze}from"../chunks/Markdown.ae01904b.js";import{H as Ne}from"../chunks/Heading.7e7e0c5b.js";import{E as es}from"../chunks/index.499f366c.js";function ts(_){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(_){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){M(s,t,c),m=!0},p:ie,i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function as(_){let s,m;return s=new ze({props:{$$slots:{default:[ss]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ls(_){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){M(s,t,c),m=!0},p:ie,i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ns(_){let s,m;return s=new ze({props:{$$slots:{default:[ls]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function rs(_){let s,m='If you aren’t familiar with finetuning a model with the <a href="/docs/transformers/main/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-15s4um0"&&(s.innerHTML=m)},m(t,c){l(t,s,c)},p:ie,d(t){t&&a(s)}}}function os(_){let s,m,t,c='You’re ready to start training your model now! Load T5 with <a href="/docs/transformers/main/en/model_doc/auto#transformers.AutoModelForSeq2SeqLM">AutoModelForSeq2SeqLM</a>:',b,Z,B,R,v="At this point, only three steps remain:",X,J,H='<li>Define your training hyperparameters in <a href="/docs/transformers/main/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/main/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/main/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/main/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/main/en/main_classes/trainer#transformers.Trainer.push_to_hub">push_to_hub()</a> method so everyone can use your model:',E,V,F;return s=new wt({props:{$$slots:{default:[rs]},$$scope:{ctx:_}}}),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:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFNlcTJTZXFUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEJTIybXlfYXdlc29tZV9vcHVzX2Jvb2tzX21vZGVsJTIyJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9zdHJhdGVneSUzRCUyMmVwb2NoJTIyJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5pbmdfcmF0ZSUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0QxNiUyQyUwQSUyMCUyMCUyMCUyMHBlcl9kZXZpY2VfZXZhbF9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV90b3RhbF9saW1pdCUzRDMlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fZXBvY2hzJTNEMiUyQyUwQSUyMCUyMCUyMCUyMHByZWRpY3Rfd2l0aF9nZW5lcmF0ZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBmcDE2JTNEVHJ1ZSUyQyUyMCUyM2NoYW5nZSUyMHRvJTIwYmYxNiUzRFRydWUlMjBmb3IlMjBYUFUlMEElMjAlMjAlMjAlMjBwdXNoX3RvX2h1YiUzRFRydWUlMkMlMEEpJTBBJTBBdHJhaW5lciUyMCUzRCUyMFNlcTJTZXFUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfYm9va3MlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUzRHRva2VuaXplZF9ib29rcyU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBwcm9jZXNzaW5nX2NsYXNzJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",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>    processing_class=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}}),V=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=v,X=p(),J=$("ol"),J.innerHTML=H,W=p(),u(k.$$.fragment),G=p(),o=$("p"),o.innerHTML=U,E=p(),u(V.$$.fragment)},l(f){h(s.$$.fragment,f),m=i(f),t=j(f,"P",{"data-svelte-h":!0}),T(t)!=="svelte-peka6h"&&(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=v),X=i(f),J=j(f,"OL",{"data-svelte-h":!0}),T(J)!=="svelte-n1d4ms"&&(J.innerHTML=H),W=i(f),h(k.$$.fragment,f),G=i(f),o=j(f,"P",{"data-svelte-h":!0}),T(o)!=="svelte-1v13hlo"&&(o.innerHTML=U),E=i(f),h(V.$$.fragment,f)},m(f,C){M(s,f,C),l(f,m,C),l(f,t,C),l(f,b,C),M(Z,f,C),l(f,B,C),l(f,R,C),l(f,X,C),l(f,J,C),l(f,W,C),M(k,f,C),l(f,G,C),l(f,o,C),l(f,E,C),M(V,f,C),F=!0},p(f,C){const I={};C&2&&(I.$$scope={dirty:C,ctx:f}),s.$set(I)},i(f){F||(y(s.$$.fragment,f),y(Z.$$.fragment,f),y(k.$$.fragment,f),y(V.$$.fragment,f),F=!0)},o(f){d(s.$$.fragment,f),d(Z.$$.fragment,f),d(k.$$.fragment,f),d(V.$$.fragment,f),F=!1},d(f){f&&(a(m),a(t),a(b),a(B),a(R),a(X),a(J),a(W),a(G),a(o),a(E)),g(s,f),g(Z,f),g(k,f),g(V,f)}}}function ps(_){let s,m;return s=new ze({props:{$$slots:{default:[os]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function is(_){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(_){let s,m,t,c,b,Z='Then you can load T5 with <a href="/docs/transformers/main/en/model_doc/auto#transformers.TFAutoModelForSeq2SeqLM">TFAutoModelForSeq2SeqLM</a>:',B,R,v,X,J='Convert your datasets to the <code>tf.data.Dataset</code> format with <a href="/docs/transformers/main/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,V,F,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,I,me='Pass your <code>compute_metrics</code> function to <a href="/docs/transformers/main/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/main/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:_}}}),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:"ZnJvbSUyMHRyYW5zZm9ybWVycy5rZXJhc19jYWxsYmFja3MlMjBpbXBvcnQlMjBLZXJhc01ldHJpY0NhbGxiYWNrJTBBJTBBbWV0cmljX2NhbGxiYWNrJTIwJTNEJTIwS2VyYXNNZXRyaWNDYWxsYmFjayhtZXRyaWNfZm4lM0Rjb21wdXRlX21ldHJpY3MlMkMlMjBldmFsX2RhdGFzZXQlM0R0Zl90ZXN0X3NldCk=",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_test_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),v=p(),X=$("p"),X.innerHTML=J,H=p(),u(W.$$.fragment),k=p(),G=$("p"),G.innerHTML=o,U=p(),u(E.$$.fragment),V=p(),F=$("p"),F.innerHTML=f,C=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-17zh4n3"&&(b.innerHTML=Z),B=i(r),h(R.$$.fragment,r),v=i(r),X=j(r,"P",{"data-svelte-h":!0}),T(X)!=="svelte-9ymftz"&&(X.innerHTML=J),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),V=i(r),F=j(r,"P",{"data-svelte-h":!0}),T(F)!=="svelte-13cue08"&&(F.innerHTML=f),C=i(r),I=j(r,"P",{"data-svelte-h":!0}),T(I)!=="svelte-bi2rpv"&&(I.innerHTML=me),N=i(r),h(z.$$.fragment,r),Y=i(r),te=j(r,"P",{"data-svelte-h":!0}),T(te)!=="svelte-1b3skyn"&&(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){M(s,r,w),l(r,m,w),M(t,r,w),l(r,c,w),l(r,b,w),l(r,B,w),M(R,r,w),l(r,v,w),l(r,X,w),l(r,H,w),M(W,r,w),l(r,k,w),l(r,G,w),l(r,U,w),M(E,r,w),l(r,V,w),l(r,F,w),l(r,C,w),l(r,I,w),l(r,N,w),M(z,r,w),l(r,Y,w),l(r,te,w),l(r,S,w),M(Q,r,w),l(r,q,w),l(r,A,w),l(r,fe,w),M(L,r,w),l(r,P,w),l(r,D,w),l(r,ue,w),M(K,r,w),l(r,O,w),l(r,ee,w),he=!0},p(r,w){const Me={};w&2&&(Me.$$scope={dirty:w,ctx:r}),s.$set(Me)},i(r){he||(y(s.$$.fragment,r),y(t.$$.fragment,r),y(R.$$.fragment,r),y(W.$$.fragment,r),y(E.$$.fragment,r),y(z.$$.fragment,r),y(Q.$$.fragment,r),y(L.$$.fragment,r),y(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(v),a(X),a(H),a(k),a(G),a(U),a(V),a(F),a(C),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(_){let s,m;return s=new ze({props:{$$slots:{default:[ms]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function fs(_){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(_){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/main/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,J,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}}),v=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(v.$$.fragment),X=p(),J=$("p"),J.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-1i7jvby"&&(Z.innerHTML=B),R=i(o),h(v.$$.fragment,o),X=i(o),J=j(o,"P",{"data-svelte-h":!0}),T(J)!=="svelte-1918fu9"&&(J.textContent=H),W=i(o),h(k.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),M(c,o,U),l(o,b,U),l(o,Z,U),l(o,R,U),M(v,o,U),l(o,X,U),l(o,J,U),l(o,W,U),M(k,o,U),G=!0},p:ie,i(o){G||(y(c.$$.fragment,o),y(v.$$.fragment,o),y(k.$$.fragment,o),G=!0)},o(o){d(c.$$.fragment,o),d(v.$$.fragment,o),d(k.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(J),a(W)),g(c,o),g(v,o),g(k,o)}}}function hs(_){let s,m;return s=new ze({props:{$$slots:{default:[us]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function Ms(_){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,v,X,J,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}}),v=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(v.$$.fragment),X=p(),J=$("p"),J.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(v.$$.fragment,o),X=i(o),J=j(o,"P",{"data-svelte-h":!0}),T(J)!=="svelte-1918fu9"&&(J.textContent=H),W=i(o),h(k.$$.fragment,o)},m(o,U){l(o,s,U),l(o,t,U),M(c,o,U),l(o,b,U),l(o,Z,U),l(o,R,U),M(v,o,U),l(o,X,U),l(o,J,U),l(o,W,U),M(k,o,U),G=!0},p:ie,i(o){G||(y(c.$$.fragment,o),y(v.$$.fragment,o),y(k.$$.fragment,o),G=!0)},o(o){d(c.$$.fragment,o),d(v.$$.fragment,o),d(k.$$.fragment,o),G=!1},d(o){o&&(a(s),a(t),a(b),a(Z),a(R),a(X),a(J),a(W)),g(c,o),g(v,o),g(k,o)}}}function ys(_){let s,m;return s=new ze({props:{$$slots:{default:[Ms]},$$scope:{ctx:_}}}),{c(){u(s.$$.fragment)},l(t){h(s.$$.fragment,t)},m(t,c){M(s,t,c),m=!0},p(t,c){const b={};c&2&&(b.$$scope={dirty:c,ctx:t}),s.$set(b)},i(t){m||(y(s.$$.fragment,t),m=!0)},o(t){d(s.$$.fragment,t),m=!1},d(t){g(s,t)}}}function ds(_){let s,m,t,c,b,Z,B,R,v,X,J,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>',V,F,f,C,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,Me,ye,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,Jt="The preprocessing function you want to create needs to:",Pe,we,_t="<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,Je,vt='Now create a batch of examples using <a href="/docs/transformers/main/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,_e,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,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,Fe,Mt,Ve,Gt='The simplest way to try out your finetuned model for inference is to use it in a <a href="/docs/transformers/main/en/main_classes/pipelines#transformers.pipeline">pipeline()</a>. Instantiate a <code>pipeline</code> for translation with your model, and pass your text to it:',yt,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"}]}}),v=new Yt({props:{id:"1JvfrvZgi6c"}}),F=new wt({props:{$$slots:{default:[ts]},$$scope:{ctx:_}}}),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:_}}}),_e=new Ne({props:{title:"Evaluate",local:"evaluate",headingTag:"h2"}}),ve=new x({props:{code:"aW1wb3J0JTIwZXZhbHVhdGUlMEElMEFtZXRyaWMlMjAlM0QlMjBldmFsdWF0ZS5sb2FkKCUyMnNhY3JlYmxldSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> evaluate

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = evaluate.load(<span class="hljs-string">&quot;sacrebleu&quot;</span>)`,wrap:!1}}),xe=new x({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBJTBBZGVmJTIwcG9zdHByb2Nlc3NfdGV4dChwcmVkcyUyQyUyMGxhYmVscyklM0ElMEElMjAlMjAlMjAlMjBwcmVkcyUyMCUzRCUyMCU1QnByZWQuc3RyaXAoKSUyMGZvciUyMHByZWQlMjBpbiUyMHByZWRzJTVEJTBBJTIwJTIwJTIwJTIwbGFiZWxzJTIwJTNEJTIwJTVCJTVCbGFiZWwuc3RyaXAoKSU1RCUyMGZvciUyMGxhYmVsJTIwaW4lMjBsYWJlbHMlNUQlMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBwcmVkcyUyQyUyMGxhYmVscyUwQSUwQSUwQWRlZiUyMGNvbXB1dGVfbWV0cmljcyhldmFsX3ByZWRzKSUzQSUwQSUyMCUyMCUyMCUyMHByZWRzJTJDJTIwbGFiZWxzJTIwJTNEJTIwZXZhbF9wcmVkcyUwQSUyMCUyMCUyMCUyMGlmJTIwaXNpbnN0YW5jZShwcmVkcyUyQyUyMHR1cGxlKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByZWRzJTIwJTNEJTIwcHJlZHMlNUIwJTVEJTBBJTIwJTIwJTIwJTIwZGVjb2RlZF9wcmVkcyUyMCUzRCUyMHRva2VuaXplci5iYXRjaF9kZWNvZGUocHJlZHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSklMEElMEElMjAlMjAlMjAlMjBsYWJlbHMlMjAlM0QlMjBucC53aGVyZShsYWJlbHMlMjAhJTNEJTIwLTEwMCUyQyUyMGxhYmVscyUyQyUyMHRva2VuaXplci5wYWRfdG9rZW5faWQpJTBBJTIwJTIwJTIwJTIwZGVjb2RlZF9sYWJlbHMlMjAlM0QlMjB0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKGxhYmVscyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKSUwQSUwQSUyMCUyMCUyMCUyMGRlY29kZWRfcHJlZHMlMkMlMjBkZWNvZGVkX2xhYmVscyUyMCUzRCUyMHBvc3Rwcm9jZXNzX3RleHQoZGVjb2RlZF9wcmVkcyUyQyUyMGRlY29kZWRfbGFiZWxzKSUwQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMG1ldHJpYy5jb21wdXRlKHByZWRpY3Rpb25zJTNEZGVjb2RlZF9wcmVkcyUyQyUyMHJlZmVyZW5jZXMlM0RkZWNvZGVkX2xhYmVscyklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjAlN0IlMjJibGV1JTIyJTNBJTIwcmVzdWx0JTVCJTIyc2NvcmUlMjIlNUQlN0QlMEElMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9uX2xlbnMlMjAlM0QlMjAlNUJucC5jb3VudF9ub256ZXJvKHByZWQlMjAhJTNEJTIwdG9rZW5pemVyLnBhZF90b2tlbl9pZCklMjBmb3IlMjBwcmVkJTIwaW4lMjBwcmVkcyU1RCUwQSUyMCUyMCUyMCUyMHJlc3VsdCU1QiUyMmdlbl9sZW4lMjIlNUQlMjAlM0QlMjBucC5tZWFuKHByZWRpY3Rpb25fbGVucyklMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjAlN0JrJTNBJTIwcm91bmQodiUyQyUyMDQpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMHJlc3VsdC5pdGVtcygpJTdEJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwcmVzdWx0",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">postprocess_text</span>(<span class="hljs-params">preds, labels</span>):
<span class="hljs-meta">... </span>    preds = [pred.strip() <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
<span class="hljs-meta">... </span>    labels = [[label.strip()] <span class="hljs-keyword">for</span> label <span class="hljs-keyword">in</span> labels]

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


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_preds</span>):
<span class="hljs-meta">... </span>    preds, labels = eval_preds
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> <span class="hljs-built_in">isinstance</span>(preds, <span class="hljs-built_in">tuple</span>):
<span class="hljs-meta">... </span>        preds = preds[<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>    decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    labels = np.where(labels != -<span class="hljs-number">100</span>, labels, tokenizer.pad_token_id)
<span class="hljs-meta">... </span>    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=<span class="hljs-literal">True</span>)

<span class="hljs-meta">... </span>    decoded_preds, decoded_labels = postprocess_text(decoded_preds, decoded_labels)

<span class="hljs-meta">... </span>    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
<span class="hljs-meta">... </span>    result = {<span class="hljs-string">&quot;bleu&quot;</span>: result[<span class="hljs-string">&quot;score&quot;</span>]}

<span class="hljs-meta">... </span>    prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) <span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds]
<span class="hljs-meta">... </span>    result[<span class="hljs-string">&quot;gen_len&quot;</span>] = np.mean(prediction_lens)
<span class="hljs-meta">... </span>    result = {k: <span class="hljs-built_in">round</span>(v, <span class="hljs-number">4</span>) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> result.items()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> result`,wrap:!1}}),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:_}}}),oe=new wt({props:{$$slots:{default:[fs]},$$scope:{ctx:_}}}),We=new Ne({props:{title:"Inference",local:"inference",headingTag:"h2"}}),Fe=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:[ys],pytorch:[hs]},$$scope:{ctx:_}}}),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(v.$$.fragment),X=p(),J=$("p"),J.textContent=H,W=p(),k=$("p"),k.textContent=G,o=p(),U=$("ol"),U.innerHTML=E,V=p(),u(F.$$.fragment),f=p(),C=$("p"),C.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),Me=p(),ye=$("p"),ye.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=Jt,Pe=p(),we=$("ol"),we.innerHTML=_t,De=p(),u(Te.$$.fragment),Ke=p(),Ue=$("p"),Ue.innerHTML=Zt,Oe=p(),u(ke.$$.fragment),et=p(),Je=$("p"),Je.innerHTML=vt,tt=p(),u(ne.$$.fragment),st=p(),u(_e.$$.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(We.$$.fragment),ft=p(),Ge=$("p"),Ge.textContent=Xt,ut=p(),Be=$("p"),Be.textContent=Wt,ht=p(),u(Fe.$$.fragment),Mt=p(),Ve=$("p"),Ve.innerHTML=Gt,yt=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(v.$$.fragment,e),X=i(e),J=j(e,"P",{"data-svelte-h":!0}),T(J)!=="svelte-x8f5ei"&&(J.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),V=i(e),h(F.$$.fragment,e),f=i(e),C=j(e,"P",{"data-svelte-h":!0}),T(C)!=="svelte-1c9nexd"&&(C.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),Me=i(e),ye=j(e,"P",{"data-svelte-h":!0}),T(ye)!=="svelte-pj869u"&&(ye.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=Jt),Pe=i(e),we=j(e,"OL",{"data-svelte-h":!0}),T(we)!=="svelte-1q1yj0j"&&(we.innerHTML=_t),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),Je=j(e,"P",{"data-svelte-h":!0}),T(Je)!=="svelte-1yb3v27"&&(Je.innerHTML=vt),tt=i(e),h(ne.$$.fragment,e),st=i(e),h(_e.$$.fragment,e),at=i(e),Ze=j(e,"P",{"data-svelte-h":!0}),T(Ze)!=="svelte-1mb37bt"&&(Ze.innerHTML=Ct),lt=i(e),h(ve.$$.fragment,e),nt=i(e),Ce=j(e,"P",{"data-svelte-h":!0}),T(Ce)!=="svelte-6baa48"&&(Ce.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(Fe.$$.fragment,e),Mt=i(e),Ve=j(e,"P",{"data-svelte-h":!0}),T(Ve)!=="svelte-1n1jyr9"&&(Ve.innerHTML=Gt),yt=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),M(b,e,n),l(e,Z,n),M(B,e,n),l(e,R,n),M(v,e,n),l(e,X,n),l(e,J,n),l(e,W,n),l(e,k,n),l(e,o,n),l(e,U,n),l(e,V,n),M(F,e,n),l(e,f,n),l(e,C,n),l(e,me,n),M(N,e,n),l(e,z,n),l(e,Y,n),l(e,ce,n),M(S,e,n),l(e,Q,n),M(q,e,n),l(e,A,n),l(e,se,n),l(e,L,n),M(P,e,n),l(e,D,n),l(e,ae,n),l(e,K,n),M(O,e,n),l(e,ee,n),l(e,le,n),l(e,r,n),M(w,e,n),l(e,Me,n),l(e,ye,n),l(e,Se,n),M(de,e,n),l(e,Qe,n),M(ge,e,n),l(e,qe,n),l(e,be,n),l(e,Ae,n),M($e,e,n),l(e,Le,n),l(e,je,n),l(e,Pe,n),l(e,we,n),l(e,De,n),M(Te,e,n),l(e,Ke,n),l(e,Ue,n),l(e,Oe,n),M(ke,e,n),l(e,et,n),l(e,Je,n),l(e,tt,n),M(ne,e,n),l(e,st,n),M(_e,e,n),l(e,at,n),l(e,Ze,n),l(e,lt,n),M(ve,e,n),l(e,nt,n),l(e,Ce,n),l(e,rt,n),M(xe,e,n),l(e,ot,n),l(e,Re,n),l(e,pt,n),M(Xe,e,n),l(e,it,n),M(re,e,n),l(e,mt,n),M(oe,e,n),l(e,ct,n),M(We,e,n),l(e,ft,n),l(e,Ge,n),l(e,ut,n),l(e,Be,n),l(e,ht,n),M(Fe,e,n),l(e,Mt,n),l(e,Ve,n),l(e,yt,n),M(He,e,n),l(e,dt,n),l(e,Ee,n),l(e,gt,n),M(pe,e,n),l(e,bt,n),M(Ie,e,n),l(e,$t,n),l(e,Ye,n),jt=!0},p(e,[n]){const Ft={};n&2&&(Ft.$$scope={dirty:n,ctx:e}),F.$set(Ft);const Vt={};n&2&&(Vt.$$scope={dirty:n,ctx:e}),ne.$set(Vt);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||(y(b.$$.fragment,e),y(B.$$.fragment,e),y(v.$$.fragment,e),y(F.$$.fragment,e),y(N.$$.fragment,e),y(S.$$.fragment,e),y(q.$$.fragment,e),y(P.$$.fragment,e),y(O.$$.fragment,e),y(w.$$.fragment,e),y(de.$$.fragment,e),y(ge.$$.fragment,e),y($e.$$.fragment,e),y(Te.$$.fragment,e),y(ke.$$.fragment,e),y(ne.$$.fragment,e),y(_e.$$.fragment,e),y(ve.$$.fragment,e),y(xe.$$.fragment,e),y(Xe.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(We.$$.fragment,e),y(Fe.$$.fragment,e),y(He.$$.fragment,e),y(pe.$$.fragment,e),y(Ie.$$.fragment,e),jt=!0)},o(e){d(b.$$.fragment,e),d(B.$$.fragment,e),d(v.$$.fragment,e),d(F.$$.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(_e.$$.fragment,e),d(ve.$$.fragment,e),d(xe.$$.fragment,e),d(Xe.$$.fragment,e),d(re.$$.fragment,e),d(oe.$$.fragment,e),d(We.$$.fragment,e),d(Fe.$$.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(J),a(W),a(k),a(o),a(U),a(V),a(f),a(C),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(Me),a(ye),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(Je),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(Ge),a(ut),a(Be),a(ht),a(Mt),a(Ve),a(yt),a(dt),a(Ee),a(gt),a(bt),a($t),a(Ye)),a(s),g(b,e),g(B,e),g(v,e),g(F,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(_e,e),g(ve,e),g(xe,e),g(Xe,e),g(re,e),g(oe,e),g(We,e),g(Fe,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(_){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vs extends qt{constructor(s){super(),At(this,s,bs,ds,St,{})}}export{vs as component};
