import{s as ri,a as Mi,o as pi,n as He}from"../chunks/scheduler.893fe8c9.js";import{S as ci,i as ui,e as U,s as i,c as d,h as oi,a as T,d as t,b as r,f as Ss,g as m,j,k as Te,l as di,m as a,n as y,o as c,D as Ce,t as p,p as J,E as _e}from"../chunks/index.6ee278c6.js";import{T as Se}from"../chunks/Tip.eab0255c.js";import{C as mi,H as Ee,E as yi}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea3ad860.js";import{Y as $s}from"../chunks/Youtube.59d04f41.js";import{C as h}from"../chunks/CodeBlock.8bdd5f33.js";import{C as ii}from"../chunks/CourseFloatingBanner.c25cfa5e.js";import{F as Ji}from"../chunks/FrameworkSwitchCourse.77a18d50.js";function Ui(I){let s,o;return s=new ii({props:{chapter:7,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter7/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter7/section3_tf.ipynb"}]}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Ti(I){let s,o;return s=new ii({props:{chapter:7,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter7/section3_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter7/section3_pt.ipynb"}]}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function wi(I){let s,o='🙋 Dacă termenii “masked language modeling” și “pretrained model” nu vă sună familiar, mergeți să verificați <a href="/course/chapter1">Capitolul 1</a>, unde vă explicăm toate aceste concepte de bază, cu videoclipuri!';return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-p8df98"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function ji(I){let s,o="Să continuăm și să descărcăm modelul DistilBERT folosind clasa <code>TFAutoModelForMaskedLM</code>:",n,u,_,w,R="Putem vedea câți parametri are acest model prin apelarea metodei <code>summary()</code>:",v,Z,z,k,B;return u=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0lMEElMEFtb2RlbF9jaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIlMEFtb2RlbCUyMCUzRCUyMFRGQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NoZWNrcG9pbnQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForMaskedLM

model_checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>
model = TFAutoModelForMaskedLM.from_pretrained(model_checkpoint)`,wrap:!1}}),Z=new h({props:{code:"bW9kZWwuc3VtbWFyeSgp",highlighted:"model.summary()",wrap:!1}}),k=new h({props:{code:"TW9kZWwlM0ElMjAlMjJ0Zl9kaXN0aWxfYmVydF9mb3JfbWFza2VkX2xtJTIyJTBBX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18lMEFMYXllciUyMCh0eXBlKSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME91dHB1dCUyMFNoYXBlJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTI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TIwbXVsdGlwbGUlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAyMzg2NjE3MCUyMCUyMCUwQSUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUzRCUwQVRvdGFsJTIwcGFyYW1zJTNBJTIwNjYlMkM5ODUlMkM1MzAlMEFUcmFpbmFibGUlMjBwYXJhbXMlM0ElMjA2NiUyQzk4NSUyQzUzMCUwQU5vbi10cmFpbmFibGUlMjBwYXJhbXMlM0ElMjAwJTBBX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18=",highlighted:`Model: <span class="hljs-string">&quot;tf_distil_bert_for_masked_lm&quot;</span>
_________________________________________________________________
Layer (<span class="hljs-built_in">type</span>)                 Output Shape              Param <span class="hljs-comment">#   </span>
=================================================================
distilbert (TFDistilBertMain multiple                  <span class="hljs-number">66362880</span>  
_________________________________________________________________
vocab_transform (Dense)      multiple                  <span class="hljs-number">590592</span>    
_________________________________________________________________
vocab_layer_norm (LayerNorma multiple                  <span class="hljs-number">1536</span>      
_________________________________________________________________
vocab_projector (TFDistilBer multiple                  <span class="hljs-number">23866170</span>  
=================================================================
Total params: <span class="hljs-number">66</span>,<span class="hljs-number">985</span>,<span class="hljs-number">530</span>
Trainable params: <span class="hljs-number">66</span>,<span class="hljs-number">985</span>,<span class="hljs-number">530</span>
Non-trainable params: <span class="hljs-number">0</span>
_________________________________________________________________`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment),_=i(),w=U("p"),w.innerHTML=R,v=i(),d(Z.$$.fragment),z=i(),d(k.$$.fragment)},l(b){s=T(b,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1ec5el9"&&(s.innerHTML=o),n=r(b),m(u.$$.fragment,b),_=r(b),w=T(b,"P",{"data-svelte-h":!0}),j(w)!=="svelte-nv8dz4"&&(w.innerHTML=R),v=r(b),m(Z.$$.fragment,b),z=r(b),m(k.$$.fragment,b)},m(b,g){a(b,s,g),a(b,n,g),y(u,b,g),a(b,_,g),a(b,w,g),a(b,v,g),y(Z,b,g),a(b,z,g),y(k,b,g),B=!0},i(b){B||(p(u.$$.fragment,b),p(Z.$$.fragment,b),p(k.$$.fragment,b),B=!0)},o(b){c(u.$$.fragment,b),c(Z.$$.fragment,b),c(k.$$.fragment,b),B=!1},d(b){b&&(t(s),t(n),t(_),t(w),t(v),t(z)),J(u,b),J(Z,b),J(k,b)}}}function bi(I){let s,o="Să continuăm și să descărcăm modelul DistilBERT folosind clasa <code>AutoModelForMaskedLM</code>:",n,u,_,w,R="Putem vedea câți parametri are acest model prin apelarea metodei <code>num_parameters()</code>:",v,Z,z,k,B;return u=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBbW9kZWxfY2hlY2twb2ludCUyMCUzRCUyMCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2hlY2twb2ludCk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMaskedLM

model_checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>
model = AutoModelForMaskedLM.from_pretrained(model_checkpoint)`,wrap:!1}}),Z=new h({props:{code:"ZGlzdGlsYmVydF9udW1fcGFyYW1ldGVycyUyMCUzRCUyMG1vZGVsLm51bV9wYXJhbWV0ZXJzKCklMjAlMkYlMjAxXzAwMF8wMDAlMEFwcmludChmJTIyJyUzRSUzRSUzRSUyMERpc3RpbEJFUlQlMjBudW1iZXIlMjBvZiUyMHBhcmFtZXRlcnMlM0ElMjAlN0Jyb3VuZChkaXN0aWxiZXJ0X251bV9wYXJhbWV0ZXJzKSU3RE0nJTIyKSUwQXByaW50KGYlMjInJTNFJTNFJTNFJTIwQkVSVCUyMG51bWJlciUyMG9mJTIwcGFyYW1ldGVycyUzQSUyMDExME0nJTIyKQ==",highlighted:`distilbert_num_parameters = model.num_parameters() / <span class="hljs-number">1_000_000</span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; DistilBERT number of parameters: <span class="hljs-subst">{<span class="hljs-built_in">round</span>(distilbert_num_parameters)}</span>M&#x27;&quot;</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; BERT number of parameters: 110M&#x27;&quot;</span>)`,wrap:!1}}),k=new h({props:{code:"JyUzRSUzRSUzRSUyMERpc3RpbEJFUlQlMjBudW1iZXIlMjBvZiUyMHBhcmFtZXRlcnMlM0ElMjA2N00nJTBBJyUzRSUzRSUzRSUyMEJFUlQlMjBudW1iZXIlMjBvZiUyMHBhcmFtZXRlcnMlM0ElMjAxMTBNJw==",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; DistilBERT number of parameters: 67M&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; BERT number of parameters: 110M&#x27;</span>`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment),_=i(),w=U("p"),w.innerHTML=R,v=i(),d(Z.$$.fragment),z=i(),d(k.$$.fragment)},l(b){s=T(b,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1o905j3"&&(s.innerHTML=o),n=r(b),m(u.$$.fragment,b),_=r(b),w=T(b,"P",{"data-svelte-h":!0}),j(w)!=="svelte-1wdkcab"&&(w.innerHTML=R),v=r(b),m(Z.$$.fragment,b),z=r(b),m(k.$$.fragment,b)},m(b,g){a(b,s,g),a(b,n,g),y(u,b,g),a(b,_,g),a(b,w,g),a(b,v,g),y(Z,b,g),a(b,z,g),y(k,b,g),B=!0},i(b){B||(p(u.$$.fragment,b),p(Z.$$.fragment,b),p(k.$$.fragment,b),B=!0)},o(b){c(u.$$.fragment,b),c(Z.$$.fragment,b),c(k.$$.fragment,b),B=!1},d(b){b&&(t(s),t(n),t(_),t(w),t(v),t(z)),J(u,b),J(Z,b),J(k,b)}}}function hi(I){let s,o;return s=new h({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIodGV4dCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIybnAlMjIpJTBBdG9rZW5fbG9naXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMpLmxvZ2l0cyUwQSUyMyUyMEZpbmQlMjB0aGUlMjBsb2NhdGlvbiUyMG9mJTIwJTVCTUFTSyU1RCUyMGFuZCUyMGV4dHJhY3QlMjBpdHMlMjBsb2dpdHMlMEFtYXNrX3Rva2VuX2luZGV4JTIwJTNEJTIwbnAuYXJnd2hlcmUoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTIwJTNEJTNEJTIwdG9rZW5pemVyLm1hc2tfdG9rZW5faWQpJTVCMCUyQyUyMDElNUQlMEFtYXNrX3Rva2VuX2xvZ2l0cyUyMCUzRCUyMHRva2VuX2xvZ2l0cyU1QjAlMkMlMjBtYXNrX3Rva2VuX2luZGV4JTJDJTIwJTNBJTVEJTBBJTIzJTIwUGljayUyMHRoZSUyMCU1Qk1BU0slNUQlMjBjYW5kaWRhdGVzJTIwd2l0aCUyMHRoZSUyMGhpZ2hlc3QlMjBsb2dpdHMlMEElMjMlMjBXZSUyMG5lZ2F0ZSUyMHRoZSUyMGFycmF5JTIwYmVmb3JlJTIwYXJnc29ydCUyMHRvJTIwZ2V0JTIwdGhlJTIwbGFyZ2VzdCUyQyUyMG5vdCUyMHRoZSUyMHNtYWxsZXN0JTJDJTIwbG9naXRzJTBBdG9wXzVfdG9rZW5zJTIwJTNEJTIwbnAuYXJnc29ydCgtbWFza190b2tlbl9sb2dpdHMpJTVCJTNBNSU1RC50b2xpc3QoKSUwQSUwQWZvciUyMHRva2VuJTIwaW4lMjB0b3BfNV90b2tlbnMlM0ElMEElMjAlMjAlMjAlMjBwcmludChmJTIyJTNFJTNFJTNFJTIwJTdCdGV4dC5yZXBsYWNlKHRva2VuaXplci5tYXNrX3Rva2VuJTJDJTIwdG9rZW5pemVyLmRlY29kZSglNUJ0b2tlbiU1RCkpJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
token_logits = model(**inputs).logits
<span class="hljs-comment"># Find the location of [MASK] and extract its logits</span>
mask_token_index = np.argwhere(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>] == tokenizer.mask_token_id)[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>]
mask_token_logits = token_logits[<span class="hljs-number">0</span>, mask_token_index, :]
<span class="hljs-comment"># Pick the [MASK] candidates with the highest logits</span>
<span class="hljs-comment"># We negate the array before argsort to get the largest, not the smallest, logits</span>
top_5_tokens = np.argsort(-mask_token_logits)[:<span class="hljs-number">5</span>].tolist()

<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> top_5_tokens:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&gt;&gt;&gt; <span class="hljs-subst">{text.replace(tokenizer.mask_token, tokenizer.decode([token]))}</span>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m1hc2tfdG9rZW4lMkMlMjB0b2tlbml6ZXIuZGVjb2RlKCU1QnRva2VuJTVEKSklN0QnJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch

inputs = tokenizer(text, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
token_logits = model(**inputs).logits
<span class="hljs-comment"># Find the location of [MASK] and extract its logits</span>
mask_token_index = torch.where(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>] == tokenizer.mask_token_id)[<span class="hljs-number">1</span>]
mask_token_logits = token_logits[<span class="hljs-number">0</span>, mask_token_index, :]
<span class="hljs-comment"># Pick the [MASK] candidates with the highest logits</span>
top_5_tokens = torch.topk(mask_token_logits, <span class="hljs-number">5</span>, dim=<span class="hljs-number">1</span>).indices[<span class="hljs-number">0</span>].tolist()

<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> top_5_tokens:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; <span class="hljs-subst">{text.replace(tokenizer.mask_token, tokenizer.decode([token]))}</span>&#x27;&quot;</span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Ii(I){let s,o="✏️ <strong>Încearcă!</strong> Creați un sample aleatoriu din segmentul <code>unsupervised</code> și verificați că labelurile nu sunt nici <code>0</code>, nici <code>1</code>. În același timp, ați putea verifica și dacă labelurile din segmentele <code>train</code> și <code>test</code> sunt într-adevăr <code>0</code> sau <code>1</code> - aceasta este o verificare utilă pe care orice practicant NLP ar trebui să o efectueze la începutul unui nou proiect!";return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1ecg9iy"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function Ci(I){let s,o='✏️ <strong>Încearcă!</strong> Unele modele Transformer, precum <a href="https://huggingface.co/google/bigbird-roberta-base" rel="nofollow">BigBird</a> și <a href="hf.co/allenai/longformer-base-4096">Longformer</a>, au o lungime de context mult mai mare decât BERT și alte modele Transformer mai vechi. Inițializați tokenizerul pentru unul dintre aceste checkpointuri și verificați dacă <code>model_max_length</code> este în concordanță cu ceea ce este menționat pe model card.';return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1wypaju"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function _i(I){let s,o="Rețineți că utilizarea unei dimensiuni mici a chunkurilor poate fi dăunător în scenariile din lumea reală, astfel încât ar trebui să utilizați o dimensiune care corespunde cazului de utilizare la care veți aplica modelul.";return{c(){s=U("p"),s.textContent=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-tdcvyb"&&(s.textContent=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function gi(I){let s,o="✏️ <strong>Încercați!</strong> Rulați fragmentul de cod de mai sus de mai multe ori pentru a vedea cum se întâmplă mascarea aleatorie în fața ochilor voștri! De asemenea, înlocuiți metoda <code>tokenizer.decode()</code> cu <code>tokenizer.convert_ids_to_tokens()</code> pentru a vedea că uneori un singur token dintr-un cuvânt dat este mascat, și nu celelalte.";return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-cf6kd0"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function ai(I){let s,o="Un efect secundar al mascării aleatorii este faptul că metricile noastre de evaluare nu vor fi deterministe atunci când folosim <code>Trainer</code>, deoarece folosim același data collator pentru seturile de antrenare și testare. Vom vedea mai târziu, când ne vom uita la aplicarea fine-tuningului cu 🤗 Accelerate, cum putem folosi flexibilitatea unei bucle de evaluare personalizate pentru a îngheța caracterul aleatoriu.";return{c(){s=U("p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lM0QlMjAlNUItMTAwJTVEJTIwKiUyMGxlbihsYWJlbHMpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwd29yZF9pZCUyMGluJTIwbnAud2hlcmUobWFzayklNUIwJTVEJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwd29yZF9pZCUyMCUzRCUyMHdvcmRfaWQuaXRlbSgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwaWR4JTIwaW4lMjBtYXBwaW5nJTVCd29yZF9pZCU1RCUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG5ld19sYWJlbHMlNUJpZHglNUQlMjAlM0QlMjBsYWJlbHMlNUJpZHglNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpbnB1dF9pZHMlNUJpZHglNUQlMjAlM0QlMjB0b2tlbml6ZXIubWFza190b2tlbl9pZCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmUlNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjBuZXdfbGFiZWxzJTBBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdGZfZGVmYXVsdF9kYXRhX2NvbGxhdG9yKGZlYXR1cmVzKQ==",highlighted:`<span class="hljs-keyword">import</span> collections
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-keyword">from</span> transformers.data.data_collator <span class="hljs-keyword">import</span> tf_default_data_collator

wwm_probability = <span class="hljs-number">0.2</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">whole_word_masking_data_collator</span>(<span class="hljs-params">features</span>):
    <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features:
        word_ids = feature.pop(<span class="hljs-string">&quot;word_ids&quot;</span>)

        <span class="hljs-comment"># Create a map between words and corresponding token indices</span>
        mapping = collections.defaultdict(<span class="hljs-built_in">list</span>)
        current_word_index = -<span class="hljs-number">1</span>
        current_word = <span class="hljs-literal">None</span>
        <span class="hljs-keyword">for</span> idx, word_id <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(word_ids):
            <span class="hljs-keyword">if</span> word_id <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>:
                <span class="hljs-keyword">if</span> word_id != current_word:
                    current_word = word_id
                    current_word_index += <span class="hljs-number">1</span>
                mapping[current_word_index].append(idx)

        <span class="hljs-comment"># Randomly mask words</span>
        mask = np.random.binomial(<span class="hljs-number">1</span>, wwm_probability, (<span class="hljs-built_in">len</span>(mapping),))
        input_ids = feature[<span class="hljs-string">&quot;input_ids&quot;</span>]
        labels = feature[<span class="hljs-string">&quot;labels&quot;</span>]
        new_labels = [-<span class="hljs-number">100</span>] * <span class="hljs-built_in">len</span>(labels)
        <span class="hljs-keyword">for</span> word_id <span class="hljs-keyword">in</span> np.where(mask)[<span class="hljs-number">0</span>]:
            word_id = word_id.item()
            <span class="hljs-keyword">for</span> idx <span class="hljs-keyword">in</span> mapping[word_id]:
                new_labels[idx] = labels[idx]
                input_ids[idx] = tokenizer.mask_token_id
        feature[<span class="hljs-string">&quot;labels&quot;</span>] = new_labels

    <span class="hljs-keyword">return</span> tf_default_data_collator(features)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Zi(I){let s,o;return s=new h({props:{code:"aW1wb3J0JTIwY29sbGVjdGlvbnMlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwZGVmYXVsdF9kYXRhX2NvbGxh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lMjBpZHglMjBpbiUyMG1hcHBpbmclNUJ3b3JkX2lkJTVEJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbmV3X2xhYmVscyU1QmlkeCU1RCUyMCUzRCUyMGxhYmVscyU1QmlkeCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGlucHV0X2lkcyU1QmlkeCU1RCUyMCUzRCUyMHRva2VuaXplci5tYXNrX3Rva2VuX2lkJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZmVhdHVyZSU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMG5ld19sYWJlbHMlMEElMEElMjAlMjAlMjAlMjByZXR1cm4lMjBkZWZhdWx0X2RhdGFfY29sbGF0b3IoZmVhdHVyZXMp",highlighted:`<span class="hljs-keyword">import</span> collections
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> default_data_collator

wwm_probability = <span class="hljs-number">0.2</span>


<span class="hljs-keyword">def</span> <span class="hljs-title function_">whole_word_masking_data_collator</span>(<span class="hljs-params">features</span>):
    <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> features:
        word_ids = feature.pop(<span class="hljs-string">&quot;word_ids&quot;</span>)

        <span class="hljs-comment"># Create a map between words and corresponding token indices</span>
        mapping = collections.defaultdict(<span class="hljs-built_in">list</span>)
        current_word_index = -<span class="hljs-number">1</span>
        current_word = <span class="hljs-literal">None</span>
        <span class="hljs-keyword">for</span> idx, word_id <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(word_ids):
            <span class="hljs-keyword">if</span> word_id <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>:
                <span class="hljs-keyword">if</span> word_id != current_word:
                    current_word = word_id
                    current_word_index += <span class="hljs-number">1</span>
                mapping[current_word_index].append(idx)

        <span class="hljs-comment"># Randomly mask words</span>
        mask = np.random.binomial(<span class="hljs-number">1</span>, wwm_probability, (<span class="hljs-built_in">len</span>(mapping),))
        input_ids = feature[<span class="hljs-string">&quot;input_ids&quot;</span>]
        labels = feature[<span class="hljs-string">&quot;labels&quot;</span>]
        new_labels = [-<span class="hljs-number">100</span>] * <span class="hljs-built_in">len</span>(labels)
        <span class="hljs-keyword">for</span> word_id <span class="hljs-keyword">in</span> np.where(mask)[<span class="hljs-number">0</span>]:
            word_id = word_id.item()
            <span class="hljs-keyword">for</span> idx <span class="hljs-keyword">in</span> mapping[word_id]:
                new_labels[idx] = labels[idx]
                input_ids[idx] = tokenizer.mask_token_id
        feature[<span class="hljs-string">&quot;labels&quot;</span>] = new_labels

    <span class="hljs-keyword">return</span> default_data_collator(features)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Bi(I){let s,o="✏️ <strong>Încercați!</strong> Rulați fragmentul de cod de mai sus de mai multe ori pentru a vedea cum se întâmplă mascarea aleatorie în fața ochilor voștri! De asemenea, înlocuiți metoda <code>tokenizer.decode()</code> cu <code>tokenizer.convert_ids_to_tokens()</code> pentru a vedea că tokenii dintr-un cuvânt dat sunt întotdeauna mascați împreună.";return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1awm0x5"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function ki(I){let s,o="Odată ce suntem conectați, putem specifica argumentele pentru <code>Trainer</code>:",n,u,_,w,R="Aici am modificat câteva dintre opțiunile implicite, inclusiv <code>logging_steps</code> pentru a ne asigura că urmărim pierderea de antrenare cu fiecare epocă. De asemenea, am folosit <code>fp16=True</code> pentru a activa antrenarea cu precizie mixtă, ceea ce ne oferă un alt impuls vitezei. În mod implicit, <code>Trainer</code> va elimina toate coloanele care nu fac parte din metoda <code>forward()</code> a modelului. Aceasta înseamnă că, dacă utilizați whole word masking collator, va trebui să setați și <code>remove_unused_columns=False</code> pentru a vă asigura că nu pierdem coloana <code>word_ids</code> în timpul antrenamentului.",v,Z,z='Rețineți că puteți specifica numele repositoriului către care doriți să faceți push cu argumentul <code>hub_model_id</code> (în special, va trebui să utilizați acest argument pentru a face push către o organizație). De exemplu, atunci când am făcut push modelului către organizația <a href="https://huggingface.co/huggingface-course" rel="nofollow"><code>huggingface-course</code></a>, am adăugat <code>hub_model_id=&quot;huggingface-course/distilbert-finetuned-imdb&quot;</code> la <code>TrainingArguments</code>. În mod implicit, repositoriul utilizat va fi în namespaceul vostru și denumit după output directory-ul pe care l-ați stabilit, deci în cazul nostru va fi <code>&quot;lewtun/distilbert-finetuned-imdb&quot;</code>.',k,B,b="Acum avem toate ingredientele pentru inițializarea <code>Trainer</code>. Aici folosim doar <code>data_collator</code> standard, dar puteți încerca whole word masking collator și să comparați rezultatele ca un exercițiu:",g,F,V,C,X="Acum suntem gata să rulăm <code>trainer.train()</code> - dar înainte de a face acest lucru, să analizăm pe scurt <em>perplexitatea</em>, care este o metrică comună de evaluare a performanței modelelor de limbaj.",Q;return u=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBYmF0Y2hfc2l6ZSUyMCUzRCUyMDY0JTBBJTIzJTIwU2hvdyUyMHRoZSUyMHRyYWluaW5nJTIwbG9zcyUyMHdpdGglMjBldmVyeSUyMGVwb2NoJTBBbG9nZ2luZ19zdGVwcyUyMCUzRCUyMGxlbihkb3duc2FtcGxlZF9kYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQpJTIwJTJGJTJGJTIwYmF0Y2hfc2l6ZSUwQW1vZGVsX25hbWUlMjAlM0QlMjBtb2RlbF9jaGVja3BvaW50LnNwbGl0KCUyMiUyRiUyMiklNUItMSU1RCUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBUcmFpbmluZ0FyZ3VtZW50cyglMEElMjAlMjAlMjAlMjBvdXRwdXRfZGlyJTNEZiUyMiU3Qm1vZGVsX25hbWUlN0QtZmluZXR1bmVkLWltZGIlMjIlMkMlMEElMjAlMjAlMjAlMjBvdmVyd3JpdGVfb3V0cHV0X2RpciUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIlMkMlMEElMjAlMjAlMjAlMjBsZWFybmluZ19yYXRlJTNEMmUtNSUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9kZWNheSUzRDAuMDElMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX3RyYWluX2JhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV9ldmFsX2JhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTBBJTIwJTIwJTIwJTIwcHVzaF90b19odWIlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZnAxNiUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBsb2dnaW5nX3N0ZXBzJTNEbG9nZ2luZ19zdGVwcyUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

batch_size = <span class="hljs-number">64</span>
<span class="hljs-comment"># Show the training loss with every epoch</span>
logging_steps = <span class="hljs-built_in">len</span>(downsampled_dataset[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size
model_name = model_checkpoint.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>]

training_args = TrainingArguments(
    output_dir=<span class="hljs-string">f&quot;<span class="hljs-subst">{model_name}</span>-finetuned-imdb&quot;</span>,
    overwrite_output_dir=<span class="hljs-literal">True</span>,
    evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>,
    learning_rate=<span class="hljs-number">2e-5</span>,
    weight_decay=<span class="hljs-number">0.01</span>,
    per_device_train_batch_size=batch_size,
    per_device_eval_batch_size=batch_size,
    push_to_hub=<span class="hljs-literal">True</span>,
    fp16=<span class="hljs-literal">True</span>,
    logging_steps=logging_steps,
)`,wrap:!1}}),F=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluZXIlMEElMEF0cmFpbmVyJTIwJTNEJTIwVHJhaW5lciglMEElMjAlMjAlMjAlMjBtb2RlbCUzRG1vZGVsJTJDJTBBJTIwJTIwJTIwJTIwYXJncyUzRHRyYWluaW5nX2FyZ3MlMkMlMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTNEZG93bnNhbXBsZWRfZGF0YXNldCU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEZG93bnNhbXBsZWRfZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBkYXRhX2NvbGxhdG9yJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUzRHRva2VuaXplciUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> Trainer

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=downsampled_dataset[<span class="hljs-string">&quot;train&quot;</span>],
    eval_dataset=downsampled_dataset[<span class="hljs-string">&quot;test&quot;</span>],
    data_collator=data_collator,
    tokenizer=tokenizer,
)`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment),_=i(),w=U("p"),w.innerHTML=R,v=i(),Z=U("p"),Z.innerHTML=z,k=i(),B=U("p"),B.innerHTML=b,g=i(),d(F.$$.fragment),V=i(),C=U("p"),C.innerHTML=X},l(G){s=T(G,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1g4pnjh"&&(s.innerHTML=o),n=r(G),m(u.$$.fragment,G),_=r(G),w=T(G,"P",{"data-svelte-h":!0}),j(w)!=="svelte-1ntxxw7"&&(w.innerHTML=R),v=r(G),Z=T(G,"P",{"data-svelte-h":!0}),j(Z)!=="svelte-cxhak2"&&(Z.innerHTML=z),k=r(G),B=T(G,"P",{"data-svelte-h":!0}),j(B)!=="svelte-1d8nnn6"&&(B.innerHTML=b),g=r(G),m(F.$$.fragment,G),V=r(G),C=T(G,"P",{"data-svelte-h":!0}),j(C)!=="svelte-7nvjao"&&(C.innerHTML=X)},m(G,$){a(G,s,$),a(G,n,$),y(u,G,$),a(G,_,$),a(G,w,$),a(G,v,$),a(G,Z,$),a(G,k,$),a(G,B,$),a(G,g,$),y(F,G,$),a(G,V,$),a(G,C,$),Q=!0},i(G){Q||(p(u.$$.fragment,G),p(F.$$.fragment,G),Q=!0)},o(G){c(u.$$.fragment,G),c(F.$$.fragment,G),Q=!1},d(G){G&&(t(s),t(n),t(_),t(w),t(v),t(Z),t(k),t(B),t(g),t(V),t(C)),J(u,G),J(F,G)}}}function Ri(I){let s,o="Odată ce ne-am conectat, putem crea dataseturile <code>tf.data</code>. Pentru a face acest lucru, vom utiliza metoda <code>prepare_tf_dataset()</code>, care utilizează modelul nostru pentru a deduce automat ce coloane ar trebui să intre în dataset. Dacă doriți să controlați exact ce coloane să utilizați, puteți folosi în schimb metoda <code>Dataset.to_tf_dataset()</code>. Pentru a simplifica lucrurile, vom utiliza aici doar data collatorul standard, dar puteți încerca și whole word masking collator și puteți compara rezultatele ca un exercițiu:",n,u,_,w,R="În continuare, setăm hiperparametrii de antrenare și compilăm modelul nostru. Utilizăm funcția <code>create_optimizer()</code> din biblioteca 🤗 Transformers, care ne oferă un optimizator <code>AdamW</code> cu o scădere liniară a ratei de învățare. Utilizăm, de asemenea, pierderea încorporată în model, care este cea implicită atunci când nu este specificată nicio pierdere ca argument pentru <code>compile()</code>, și setăm precizia de antrenare la <code>&quot;mixed_float16&quot;</code>. Rețineți că, dacă utilizați un GPU Colab sau alt GPU care nu are suport accelerat pentru float16, ar trebui probabil să comentați această linie.",v,Z,z='În plus, am configurat un <code>PushToHubCallback</code> care va salva modelul în Hub după fiecare epocă. Puteți specifica numele repositoriului către care doriți să faceți push cu argumentul <code>hub_model_id</code> (în special, va trebui să utilizați acest argument pentru a face push către o organizație). De exemplu, pentru a trimite modelul către organizația <a href="https://huggingface.co/huggingface-course" rel="nofollow"><code>huggingface-course</code></a>, am adăugat <code>hub_model_id=&quot;huggingface-course/distilbert-finetuned-imdb&quot;</code>. În mod implicit, repositoriul utilizat va fi în namespaceul vostru și numit după output directory-ul pe care l-ați stabilit, deci în cazul nostru va fi <code>&quot;lewtun/distilbert-finetuned-imdb&quot;</code>.',k,B,b,g,F="Acum suntem gata să executăm <code>model.fit()</code> - dar înainte de a face acest lucru, să ne uităm pe scurt la <em>perplexitate</em>, care este o metrică comună pentru a evalua performanța modelelor de limbaj.",V;return u=new h({props:{code:"dGZfdHJhaW5fZGF0YXNldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjBkb3duc2FtcGxlZF9kYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDMyJTJDJTBBKSUwQSUwQXRmX2V2YWxfZGF0YXNldCUyMCUzRCUyMG1vZGVsLnByZXBhcmVfdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjBkb3duc2FtcGxlZF9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDMyJTJDJTBBKQ==",highlighted:`tf_train_dataset = model.prepare_tf_dataset(
    downsampled_dataset[<span class="hljs-string">&quot;train&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">True</span>,
    batch_size=<span class="hljs-number">32</span>,
)

tf_eval_dataset = model.prepare_tf_dataset(
    downsampled_dataset[<span class="hljs-string">&quot;test&quot;</span>],
    collate_fn=data_collator,
    shuffle=<span class="hljs-literal">False</span>,
    batch_size=<span class="hljs-number">32</span>,
)`,wrap:!1}}),B=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEFmcm9tJTIwdHJhbnNmb3JtZXJzLmtlcmFzX2NhbGxiYWNrcyUyMGltcG9ydCUyMFB1c2hUb0h1YkNhbGxiYWNrJTBBaW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFudW1fdHJhaW5fc3RlcHMlMjAlM0QlMjBsZW4odGZfdHJhaW5fZGF0YXNldCklMEFvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZSUyMCUzRCUyMGNyZWF0ZV9vcHRpbWl6ZXIoJTBBJTIwJTIwJTIwJTIwaW5pdF9sciUzRDJlLTUlMkMlMEElMjAlMjAlMjAlMjBudW1fd2FybXVwX3N0ZXBzJTNEMV8wMDAlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5fc3RlcHMlM0RudW1fdHJhaW5fc3RlcHMlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXlfcmF0ZSUzRDAuMDElMkMlMEEpJTBBbW9kZWwuY29tcGlsZShvcHRpbWl6ZXIlM0RvcHRpbWl6ZXIpJTBBJTBBJTIzJTIwVHJhaW4lMjBpbiUyMG1peGVkLXByZWNpc2lvbiUyMGZsb2F0MTYlMEF0Zi5rZXJhcy5taXhlZF9wcmVjaXNpb24uc2V0X2dsb2JhbF9wb2xpY3koJTIybWl4ZWRfZmxvYXQxNiUyMiklMEElMEFtb2RlbF9uYW1lJTIwJTNEJTIwbW9kZWxfY2hlY2twb2ludC5zcGxpdCglMjIlMkYlMjIpJTVCLTElNUQlMEFjYWxsYmFjayUyMCUzRCUyMFB1c2hUb0h1YkNhbGxiYWNrKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0RmJTIyJTdCbW9kZWxfbmFtZSU3RC1maW5ldHVuZWQtaW1kYiUyMiUyQyUyMHRva2VuaXplciUzRHRva2VuaXplciUwQSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<span class="hljs-keyword">from</span> transformers.keras_callbacks <span class="hljs-keyword">import</span> PushToHubCallback
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

num_train_steps = <span class="hljs-built_in">len</span>(tf_train_dataset)
optimizer, schedule = create_optimizer(
    init_lr=<span class="hljs-number">2e-5</span>,
    num_warmup_steps=<span class="hljs-number">1_000</span>,
    num_train_steps=num_train_steps,
    weight_decay_rate=<span class="hljs-number">0.01</span>,
)
model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)

<span class="hljs-comment"># Train in mixed-precision float16</span>
tf.keras.mixed_precision.set_global_policy(<span class="hljs-string">&quot;mixed_float16&quot;</span>)

model_name = model_checkpoint.split(<span class="hljs-string">&quot;/&quot;</span>)[-<span class="hljs-number">1</span>]
callback = PushToHubCallback(
    output_dir=<span class="hljs-string">f&quot;<span class="hljs-subst">{model_name}</span>-finetuned-imdb&quot;</span>, tokenizer=tokenizer
)`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment),_=i(),w=U("p"),w.innerHTML=R,v=i(),Z=U("p"),Z.innerHTML=z,k=i(),d(B.$$.fragment),b=i(),g=U("p"),g.innerHTML=F},l(C){s=T(C,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1ew67dq"&&(s.innerHTML=o),n=r(C),m(u.$$.fragment,C),_=r(C),w=T(C,"P",{"data-svelte-h":!0}),j(w)!=="svelte-19uajgb"&&(w.innerHTML=R),v=r(C),Z=T(C,"P",{"data-svelte-h":!0}),j(Z)!=="svelte-11qfh74"&&(Z.innerHTML=z),k=r(C),m(B.$$.fragment,C),b=r(C),g=T(C,"P",{"data-svelte-h":!0}),j(g)!=="svelte-drf4xh"&&(g.innerHTML=F)},m(C,X){a(C,s,X),a(C,n,X),y(u,C,X),a(C,_,X),a(C,w,X),a(C,v,X),a(C,Z,X),a(C,k,X),y(B,C,X),a(C,b,X),a(C,g,X),V=!0},i(C){V||(p(u.$$.fragment,C),p(B.$$.fragment,C),V=!0)},o(C){c(u.$$.fragment,C),c(B.$$.fragment,C),V=!1},d(C){C&&(t(s),t(n),t(_),t(w),t(v),t(Z),t(k),t(b),t(g)),J(u,C),J(B,C)}}}function vi(I){let s,o="Presupunând că setul nostru de testare constă în cea mai mare parte din propoziții corecte din punct de vedere gramatical, atunci o modalitate de a măsura calitatea modelului nostru lingvistic este de a calcula probabilitățile pe care le atribuie următorului cuvânt în toate propozițiile din setul de testare. Probabilitățile ridicate indică faptul că modelul indică faptul că modelul nu este “surprins” sau “perplex” de exemplele nevăzute și sugerează că a învățat modelele de bază ale gramaticii limbii. Există diverse definiții matematice ale perplexității, dar cea pe care o vom folosi o definește ca the exponential of the cross-entropy loss. Astfel, putem calcula perplexitatea modelului nostru preantrenat folosind metoda <code>model.evaluate()</code> pentru a calcula pierderea de entropie încrucișată pe setul de testare și apoi luând exponențiala rezultatului:",n,u,_;return u=new h({props:{code:"aW1wb3J0JTIwbWF0aCUwQSUwQWV2YWxfbG9zcyUyMCUzRCUyMG1vZGVsLmV2YWx1YXRlKHRmX2V2YWxfZGF0YXNldCklMEFwcmludChmJTIyUGVycGxleGl0eSUzQSUyMCU3Qm1hdGguZXhwKGV2YWxfbG9zcyklM0EuMmYlN0QlMjIp",highlighted:`<span class="hljs-keyword">import</span> math

eval_loss = model.evaluate(tf_eval_dataset)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Perplexity: <span class="hljs-subst">{math.exp(eval_loss):<span class="hljs-number">.2</span>f}</span>&quot;</span>)`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment)},l(w){s=T(w,"P",{"data-svelte-h":!0}),j(s)!=="svelte-bzoqdy"&&(s.innerHTML=o),n=r(w),m(u.$$.fragment,w)},m(w,R){a(w,s,R),a(w,n,R),y(u,w,R),_=!0},i(w){_||(p(u.$$.fragment,w),_=!0)},o(w){c(u.$$.fragment,w),_=!1},d(w){w&&(t(s),t(n)),J(u,w)}}}function zi(I){let s,o="Presupunând că setul nostru de testare constă în cea mai mare parte din propoziții corecte din punct de vedere gramatical, atunci o modalitate de a măsura calitatea modelului nostru lingvistic este de a calcula probabilitățile pe care le atribuie următorului cuvânt în toate propozițiile din setul de testare. Probabilitatea ridicată indică faptul că modelul nu este “surprins” sau “perplex” de exemplele nevăzute și sugerează că a învățat tiparele gramaticale de bază ale limbii. Există diverse definiții matematice ale perplexității, dar cea pe care o vom utiliza o definește ca the exponential of the cross-entropy loss. Astfel, putem calcula perplexitatea modelului nostru preantrenat utilizând funcția <code>Trainer.evaluate()</code> pentru a calcula pierderea de cross-entropy pe setul de testare și apoi luând exponențiala rezultatului:",n,u,_;return u=new h({props:{code:"aW1wb3J0JTIwbWF0aCUwQSUwQWV2YWxfcmVzdWx0cyUyMCUzRCUyMHRyYWluZXIuZXZhbHVhdGUoKSUwQXByaW50KGYlMjIlM0UlM0UlM0UlMjBQZXJwbGV4aXR5JTNBJTIwJTdCbWF0aC5leHAoZXZhbF9yZXN1bHRzJTVCJ2V2YWxfbG9zcyclNUQpJTNBLjJmJTdEJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> math

eval_results = trainer.evaluate()
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&gt;&gt;&gt; Perplexity: <span class="hljs-subst">{math.exp(eval_results[<span class="hljs-string">&#x27;eval_loss&#x27;</span>]):<span class="hljs-number">.2</span>f}</span>&quot;</span>)`,wrap:!1}}),{c(){s=U("p"),s.innerHTML=o,n=i(),d(u.$$.fragment)},l(w){s=T(w,"P",{"data-svelte-h":!0}),j(s)!=="svelte-104exk3"&&(s.innerHTML=o),n=r(w),m(u.$$.fragment,w)},m(w,R){a(w,s,R),a(w,n,R),y(u,w,R),_=!0},i(w){_||(p(u.$$.fragment,w),_=!0)},o(w){c(u.$$.fragment,w),_=!1},d(w){w&&(t(s),t(n)),J(u,w)}}}function Xi(I){let s,o;return s=new h({props:{code:"bW9kZWwuZml0KHRmX3RyYWluX2RhdGFzZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl9ldmFsX2RhdGFzZXQlMkMlMjBjYWxsYmFja3MlM0QlNUJjYWxsYmFjayU1RCk=",highlighted:"model.fit(tf_train_dataset, validation_data=tf_eval_dataset, callbacks=[callback])",wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function $i(I){let s,o;return s=new h({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:"trainer.train()",wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Wi(I){let s,o;return s=new h({props:{code:"ZXZhbF9sb3NzJTIwJTNEJTIwbW9kZWwuZXZhbHVhdGUodGZfZXZhbF9kYXRhc2V0KSUwQXByaW50KGYlMjJQZXJwbGV4aXR5JTNBJTIwJTdCbWF0aC5leHAoZXZhbF9sb3NzKSUzQS4yZiU3RCUyMik=",highlighted:`eval_loss = model.evaluate(tf_eval_dataset)
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;Perplexity: <span class="hljs-subst">{math.exp(eval_loss):<span class="hljs-number">.2</span>f}</span>&quot;</span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function Vi(I){let s,o;return s=new h({props:{code:"ZXZhbF9yZXN1bHRzJTIwJTNEJTIwdHJhaW5lci5ldmFsdWF0ZSgpJTBBcHJpbnQoZiUyMiUzRSUzRSUzRSUyMFBlcnBsZXhpdHklM0ElMjAlN0JtYXRoLmV4cChldmFsX3Jlc3VsdHMlNUInZXZhbF9sb3NzJyU1RCklM0EuMmYlN0QlMjIp",highlighted:`eval_results = trainer.evaluate()
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&gt;&gt;&gt; Perplexity: <span class="hljs-subst">{math.exp(eval_results[<span class="hljs-string">&#x27;eval_loss&#x27;</span>]):<span class="hljs-number">.2</span>f}</span>&quot;</span>)`,wrap:!1}}),{c(){d(s.$$.fragment)},l(n){m(s.$$.fragment,n)},m(n,u){y(s,n,u),o=!0},i(n){o||(p(s.$$.fragment,n),o=!0)},o(n){c(s.$$.fragment,n),o=!1},d(n){J(s,n)}}}function si(I){let s,o="Odată ce antrenarea este finalizată, putem trimite cardul modelului cu informațiile de antrenare către Hub (checkpointurile sunt salvate în timpul antrenare):",n,u,_;return u=new h({props:{code:"dHJhaW5lci5wdXNoX3RvX2h1Yigp",highlighted:"trainer.push_to_hub()",wrap:!1}}),{c(){s=U("p"),s.textContent=o,n=i(),d(u.$$.fragment)},l(w){s=T(w,"P",{"data-svelte-h":!0}),j(s)!=="svelte-75txcs"&&(s.textContent=o),n=r(w),m(u.$$.fragment,w)},m(w,R){a(w,s,R),a(w,n,R),y(u,w,R),_=!0},i(w){_||(p(u.$$.fragment,w),_=!0)},o(w){c(u.$$.fragment,w),_=!1},d(w){w&&(t(s),t(n)),J(u,w)}}}function xi(I){let s,o="✏️ <strong>Rândul tău!</strong> Rulați antrenamentul de mai sus după schimbarea data collatorului cu whole word masking collator. Obțineți rezultate mai bune?";return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-3ph1g7"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function ni(I){let s,o="În cazul nostru de utilizare, nu a fost nevoie să facem nimic special cu bucla de antrenare, dar în unele cazuri s-ar putea să fie nevoie să implementați o logică personalizată. Pentru aceste aplicații, puteți utiliza 🤗 Accelerate — să aruncăm o privire!",n,u,_,w,R='Așa cum am văzut cu <code>Trainer</code>, fine-tuningul unui model de limbaj mascat este foarte asemănător cu exemplul de clasificare a textului din <a href="/course/chapter3">Capitolul 3</a>. De fapt, singura subtilitate este utilizarea unui data collator special, pe care l-am abordat mai devreme în această secțiune!',v,Z,z="Cu toate acestea, am văzut că <code>DataCollatorForLanguageModeling</code> aplică, de asemenea, o mascare aleatorie cu fiecare evaluare, astfel încât vom vedea unele fluctuații în scorurile noastre de perplexitate cu fiecare rulare de antrenament. O modalitate de a elimina această sursă de dezordine este de a aplica mascarea <em>o singură dată</em> pe întregul set de teste și apoi de a utiliza data collatorul implicit din 🤗 Transformers pentru a colecta batch-urile în timpul evaluării. Pentru a vedea cum funcționează acest lucru, să implementăm o funcție simplă care aplică mascarea pe un batch, similară cu prima noastră întâlnire cu <code>DataCollatorForLanguageModeling</code>:",k,B,b,g,F="În continuare, vom aplica această funcție setului nostru de testare și vom elimina coloanele nemascate pentru a le putea înlocui cu cele mascate. Puteți utiliza whole word masking prin înlocuirea <code>data_collator</code> de mai sus cu cel corespunzător, caz în care trebuie să eliminați prima linie de aici:",V,C,X,Q,G="Putem configura apoi dataloaderele ca de obicei, dar vom folosi <code>default_data_collator</code> de la 🤗 Transformers pentru setul de evaluare:",$,le,ee,we,Le="De aici, vom urma pașii standard cu 🤗 Accelerate. În primul rând, se încarcă o versiune nouă a modelului antrenat:",te,je,ge,W,Ht="Apoi trebuie să specificăm optimizatorul; vom folosi standardul <code>AdamW</code>:",Ge,H,De,ae,be="Cu aceste obiecte, acum putem pregăti totul pentru antrenare cu obiectul <code>Accelerator</code>:",Ze,Y,Be,L,qe="Acum că modelul, optimizatorul și dataloaderul sunt configurate, putem specifica learning rate schedulerul cum urmează:",se,he,ke,S,Lt="Mai este un singur lucru de făcut înainte de antrenare: creați un repositoriu de modele pe Hugging Face Hub! Putem utiliza biblioteca 🤗 Hub pentru a genera mai întâi numele complet al repositoriul nostru:",Re,D,Ke,ne,E,x,ve="apoi creați și clonați repositoriul folosind clasa <code>Repository</code> din 🤗 Hub:",ie,fe,ze,q,Pe="Odată ce acest lucru este făcut, trebuie doar să scriem ciclul complet de antrenare și evaluare:",re,Ie,Xe,K,$e,P,Dt="Mișto, am reușit să evaluăm perplexitatea cu fiecare epocă și să ne asigurăm că mai multe runde de antrenament sunt reproductibile!",We;return u=new Ee({props:{title:"Fine-tuningul DistilBERT cu 🤗 Accelerate",local:"fine-tuning-distilbert-with-accelerate",headingTag:"h2"}}),B=new h({props:{code:"ZGVmJTIwaW5zZXJ0X3JhbmRvbV9tYXNrKGJhdGNoKSUzQSUwQSUyMCUyMCUyMCUyMGZlYXR1cmVzJTIwJTNEJTIwJTVCZGljdCh6aXAoYmF0Y2glMkMlMjB0KSklMjBmb3IlMjB0JTIwaW4lMjB6aXAoKmJhdGNoLnZhbHVlcygpKSU1RCUwQSUyMCUyMCUyMCUyMG1hc2tlZF9pbnB1dHMlMjAlM0QlMjBkYXRhX2NvbGxhdG9yKGZlYXR1cmVzKSUwQSUyMCUyMCUyMCUyMCUyMyUyMENyZWF0ZSUyMGElMjBuZXclMjAlMjJtYXNrZWQlMjIlMjBjb2x1bW4lMjBmb3IlMjBlYWNoJTIwY29sdW1uJTIwaW4lMjB0aGUlMjBkYXRhc2V0JTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTdCJTIybWFza2VkXyUyMiUyMCUyQiUyMGslM0ElMjB2Lm51bXB5KCklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwbWFza2VkX2lucHV0cy5pdGVtcygpJTdE",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">insert_random_mask</span>(<span class="hljs-params">batch</span>):
    features = [<span class="hljs-built_in">dict</span>(<span class="hljs-built_in">zip</span>(batch, t)) <span class="hljs-keyword">for</span> t <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(*batch.values())]
    masked_inputs = data_collator(features)
    <span class="hljs-comment"># Create a new &quot;masked&quot; column for each column in the dataset</span>
    <span class="hljs-keyword">return</span> {<span class="hljs-string">&quot;masked_&quot;</span> + k: v.numpy() <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> masked_inputs.items()}`,wrap:!1}}),C=new h({props:{code:"ZG93bnNhbXBsZWRfZGF0YXNldCUyMCUzRCUyMGRvd25zYW1wbGVkX2RhdGFzZXQucmVtb3ZlX2NvbHVtbnMoJTVCJTIyd29yZF9pZHMlMjIlNUQpJTBBZXZhbF9kYXRhc2V0JTIwJTNEJTIwZG93bnNhbXBsZWRfZGF0YXNldCU1QiUyMnRlc3QlMjIlNUQubWFwKCUwQSUyMCUyMCUyMCUyMGluc2VydF9yYW5kb21fbWFzayUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoZWQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwcmVtb3ZlX2NvbHVtbnMlM0Rkb3duc2FtcGxlZF9kYXRhc2V0JTVCJTIydGVzdCUyMiU1RC5jb2x1bW5fbmFtZXMlMkMlMEEpJTBBZXZhbF9kYXRhc2V0JTIwJTNEJTIwZXZhbF9kYXRhc2V0LnJlbmFtZV9jb2x1bW5zKCUwQSUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1hc2tlZF9pbnB1dF9pZHMlMjIlM0ElMjAlMjJpbnB1dF9pZHMlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJtYXNrZWRfYXR0ZW50aW9uX21hc2slMjIlM0ElMjAlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1hc2tlZF9sYWJlbHMlMjIlM0ElMjAlMjJsYWJlbHMlMjIlMkMlMEElMjAlMjAlMjAlMjAlN0QlMEEp",highlighted:`downsampled_dataset = downsampled_dataset.remove_columns([<span class="hljs-string">&quot;word_ids&quot;</span>])
eval_dataset = downsampled_dataset[<span class="hljs-string">&quot;test&quot;</span>].<span class="hljs-built_in">map</span>(
    insert_random_mask,
    batched=<span class="hljs-literal">True</span>,
    remove_columns=downsampled_dataset[<span class="hljs-string">&quot;test&quot;</span>].column_names,
)
eval_dataset = eval_dataset.rename_columns(
    {
        <span class="hljs-string">&quot;masked_input_ids&quot;</span>: <span class="hljs-string">&quot;input_ids&quot;</span>,
        <span class="hljs-string">&quot;masked_attention_mask&quot;</span>: <span class="hljs-string">&quot;attention_mask&quot;</span>,
        <span class="hljs-string">&quot;masked_labels&quot;</span>: <span class="hljs-string">&quot;labels&quot;</span>,
    }
)`,wrap:!1}}),le=new h({props:{code:"ZnJvbSUyMHRvcmNoLnV0aWxzLmRhdGElMjBpbXBvcnQlMjBEYXRhTG9hZGVyJTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGRlZmF1bHRfZGF0YV9jb2xsYXRvciUwQSUwQWJhdGNoX3NpemUlMjAlM0QlMjA2NCUwQXRyYWluX2RhdGFsb2FkZXIlMjAlM0QlMjBEYXRhTG9hZGVyKCUwQSUyMCUyMCUyMCUyMGRvd25zYW1wbGVkX2RhdGFzZXQlNUIlMjJ0cmFpbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGJhdGNoX3NpemUlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEFldmFsX2RhdGFsb2FkZXIlMjAlM0QlMjBEYXRhTG9hZGVyKCUwQSUyMCUyMCUyMCUyMGV2YWxfZGF0YXNldCUyQyUyMGJhdGNoX3NpemUlM0RiYXRjaF9zaXplJTJDJTIwY29sbGF0ZV9mbiUzRGRlZmF1bHRfZGF0YV9jb2xsYXRvciUwQSk=",highlighted:`<span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> default_data_collator

batch_size = <span class="hljs-number">64</span>
train_dataloader = DataLoader(
    downsampled_dataset[<span class="hljs-string">&quot;train&quot;</span>],
    shuffle=<span class="hljs-literal">True</span>,
    batch_size=batch_size,
    collate_fn=data_collator,
)
eval_dataloader = DataLoader(
    eval_dataset, batch_size=batch_size, collate_fn=default_data_collator
)`,wrap:!1}}),je=new h({props:{code:"bW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2hlY2twb2ludCk=",highlighted:'model = <span class="hljs-module-access"><span class="hljs-module"><span class="hljs-identifier">AutoModelForMaskedLM</span>.</span></span>from<span class="hljs-constructor">_pretrained(<span class="hljs-params">model_checkpoint</span>)</span>',wrap:!1}}),H=new h({props:{code:"ZnJvbSUyMHRvcmNoLm9wdGltJTIwaW1wb3J0JTIwQWRhbVclMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtVyhtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBsciUzRDVlLTUp",highlighted:`<span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`,wrap:!1}}),Y=new h({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IoKSUwQW1vZGVsJTJDJTIwb3B0aW1pemVyJTJDJTIwdHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlMkMlMjBvcHRpbWl6ZXIlMkMlMjB0cmFpbl9kYXRhbG9hZGVyJTJDJTIwZXZhbF9kYXRhbG9hZGVyJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

accelerator = Accelerator()
model, optimizer, train_dataloader, eval_dataloader = accelerator.prepare(
    model, optimizer, train_dataloader, eval_dataloader
)`,wrap:!1}}),he=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGdldF9zY2hlZHVsZXIlMEElMEFudW1fdHJhaW5fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV91cGRhdGVfc3RlcHNfcGVyX2Vwb2NoJTIwJTNEJTIwbGVuKHRyYWluX2RhdGFsb2FkZXIpJTBBbnVtX3RyYWluaW5nX3N0ZXBzJTIwJTNEJTIwbnVtX3RyYWluX2Vwb2NocyUyMColMjBudW1fdXBkYXRlX3N0ZXBzX3Blcl9lcG9jaCUwQSUwQWxyX3NjaGVkdWxlciUyMCUzRCUyMGdldF9zY2hlZHVsZXIoJTBBJTIwJTIwJTIwJTIwJTIybGluZWFyJTIyJTJDJTBBJTIwJTIwJTIwJTIwb3B0aW1pemVyJTNEb3B0aW1pemVyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMEElMjAlMjAlMjAlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RudW1fdHJhaW5pbmdfc3RlcHMlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

num_train_epochs = <span class="hljs-number">3</span>
num_update_steps_per_epoch = <span class="hljs-built_in">len</span>(train_dataloader)
num_training_steps = num_train_epochs * num_update_steps_per_epoch

lr_scheduler = get_scheduler(
    <span class="hljs-string">&quot;linear&quot;</span>,
    optimizer=optimizer,
    num_warmup_steps=<span class="hljs-number">0</span>,
    num_training_steps=num_training_steps,
)`,wrap:!1}}),D=new h({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGdldF9mdWxsX3JlcG9fbmFtZSUwQSUwQW1vZGVsX25hbWUlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtaW1kYi1hY2NlbGVyYXRlJTIyJTBBcmVwb19uYW1lJTIwJTNEJTIwZ2V0X2Z1bGxfcmVwb19uYW1lKG1vZGVsX25hbWUpJTBBcmVwb19uYW1l",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> get_full_repo_name

model_name = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-imdb-accelerate&quot;</span>
repo_name = get_full_repo_name(model_name)
repo_name`,wrap:!1}}),ne=new h({props:{code:"J2xld3R1biUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkLWZpbmV0dW5lZC1pbWRiLWFjY2VsZXJhdGUn",highlighted:'<span class="hljs-string">&#x27;lewtun/distilbert-base-uncased-finetuned-imdb-accelerate&#x27;</span>',wrap:!1}}),fe=new h({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMFJlcG9zaXRvcnklMEElMEFvdXRwdXRfZGlyJTIwJTNEJTIwbW9kZWxfbmFtZSUwQXJlcG8lMjAlM0QlMjBSZXBvc2l0b3J5KG91dHB1dF9kaXIlMkMlMjBjbG9uZV9mcm9tJTNEcmVwb19uYW1lKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> Repository

output_dir = model_name
repo = Repository(output_dir, clone_from=repo_name)`,wrap:!1}}),Ie=new h({props:{code:"ZnJvbSUyMHRxZG0uYXV0byUyMGltcG9ydCUyMHRxZG0lMEFpbXBvcnQlMjB0b3JjaCUwQWltcG9ydCUyMG1hdGglMEElMEFwcm9ncmVzc19iYXIlMjAlM0QlMjB0cWRtKHJhbmdlKG51bV90cmFpbmluZ19zdGVwcykpJTBBJTBBZm9yJTIwZXBvY2glMjBpbiUyMHJhbmdlKG51bV90cmFpbl9lcG9jaHMpJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwVHJhaW5pbmclMEElMjAlMjAlMjAlMjBtb2RlbC50cmFpbigpJTBBJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMHRyYWluX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWNjZWxlcmF0b3IuYmFja3dhcmQobG9zcyklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuc3RlcCgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbHJfc2NoZWR1bGVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplci56ZXJvX2dyYWQoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByb2dyZXNzX2Jhci51cGRhdGUoMSklMEElMEElMjAlMjAlMjAlMjAlMjMlMjBFdmFsdWF0aW9uJTBBJTIwJTIwJTIwJTIwbW9kZWwuZXZhbCgpJTBBJTIwJTIwJTIwJTIwbG9zc2VzJTIwJTNEJTIwJTVCJTVEJTBBJTIwJT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yMCUyMCUyMCUyMGFjY2VsZXJhdG9yLndhaXRfZm9yX2V2ZXJ5b25lKCklMEElMjAlMjAlMjAlMjB1bndyYXBwZWRfbW9kZWwlMjAlM0QlMjBhY2NlbGVyYXRvci51bndyYXBfbW9kZWwobW9kZWwpJTBBJTIwJTIwJTIwJTIwdW53cmFwcGVkX21vZGVsLnNhdmVfcHJldHJhaW5lZChvdXRwdXRfZGlyJTJDJTIwc2F2ZV9mdW5jdGlvbiUzRGFjY2VsZXJhdG9yLnNhdmUpJTBBJTIwJTIwJTIwJTIwaWYlMjBhY2NlbGVyYXRvci5pc19tYWluX3Byb2Nlc3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b2tlbml6ZXIuc2F2ZV9wcmV0cmFpbmVkKG91dHB1dF9kaXIpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwby5wdXNoX3RvX2h1YiglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjb21taXRfbWVzc2FnZSUzRGYlMjJUcmFpbmluZyUyMGluJTIwcHJvZ3Jlc3MlMjBlcG9jaCUyMCU3QmVwb2NoJTdEJTIyJTJDJTIwYmxvY2tpbmclM0RGYWxzZSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCk=",highlighted:`<span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> math

progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_train_epochs):
    <span class="hljs-comment"># Training</span>
    model.train()
    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
        outputs = model(**batch)
        loss = outputs.loss
        accelerator.backward(loss)

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(<span class="hljs-number">1</span>)

    <span class="hljs-comment"># Evaluation</span>
    model.<span class="hljs-built_in">eval</span>()
    losses = []
    <span class="hljs-keyword">for</span> step, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(eval_dataloader):
        <span class="hljs-keyword">with</span> torch.no_grad():
            outputs = model(**batch)

        loss = outputs.loss
        losses.append(accelerator.gather(loss.repeat(batch_size)))

    losses = torch.cat(losses)
    losses = losses[: <span class="hljs-built_in">len</span>(eval_dataset)]
    <span class="hljs-keyword">try</span>:
        perplexity = math.exp(torch.mean(losses))
    <span class="hljs-keyword">except</span> OverflowError:
        perplexity = <span class="hljs-built_in">float</span>(<span class="hljs-string">&quot;inf&quot;</span>)

    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&gt;&gt;&gt; Epoch <span class="hljs-subst">{epoch}</span>: Perplexity: <span class="hljs-subst">{perplexity}</span>&quot;</span>)

    <span class="hljs-comment"># Save and upload</span>
    accelerator.wait_for_everyone()
    unwrapped_model = accelerator.unwrap_model(model)
    unwrapped_model.save_pretrained(output_dir, save_function=accelerator.save)
    <span class="hljs-keyword">if</span> accelerator.is_main_process:
        tokenizer.save_pretrained(output_dir)
        repo.push_to_hub(
            commit_message=<span class="hljs-string">f&quot;Training in progress epoch <span class="hljs-subst">{epoch}</span>&quot;</span>, blocking=<span class="hljs-literal">False</span>
        )`,wrap:!1}}),K=new h({props:{code:"RXBvY2glMjAwJTNBJTIwUGVycGxleGl0eSUzQSUyMDExLjM5NzU0NTMwNzkwMDQ3MiUwQUVwb2NoJTIwMSUzQSUyMFBlcnBsZXhpdHklM0ElMjAxMC45MDQ5MDkzMzA5ODMwOTIlMEFFcG9jaCUyMDIlM0ElMjBQZXJwbGV4aXR5JTNBJTIwMTAuNzI5NTAzNTA1MzQwNDA5",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>Epoch <span class="hljs-number">0</span>: Perplexity: <span class="hljs-number">11.397545307900472</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>Epoch <span class="hljs-number">1</span>: Perplexity: <span class="hljs-number">10.904909330983092</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>Epoch <span class="hljs-number">2</span>: Perplexity: <span class="hljs-number">10.729503505340409</span>`,wrap:!1}}),{c(){s=U("p"),s.textContent=o,n=i(),d(u.$$.fragment),_=i(),w=U("p"),w.innerHTML=R,v=i(),Z=U("p"),Z.innerHTML=z,k=i(),d(B.$$.fragment),b=i(),g=U("p"),g.innerHTML=F,V=i(),d(C.$$.fragment),X=i(),Q=U("p"),Q.innerHTML=G,$=i(),d(le.$$.fragment),ee=i(),we=U("p"),we.textContent=Le,te=i(),d(je.$$.fragment),ge=i(),W=U("p"),W.innerHTML=Ht,Ge=i(),d(H.$$.fragment),De=i(),ae=U("p"),ae.innerHTML=be,Ze=i(),d(Y.$$.fragment),Be=i(),L=U("p"),L.textContent=qe,se=i(),d(he.$$.fragment),ke=i(),S=U("p"),S.textContent=Lt,Re=i(),d(D.$$.fragment),Ke=i(),d(ne.$$.fragment),E=i(),x=U("p"),x.innerHTML=ve,ie=i(),d(fe.$$.fragment),ze=i(),q=U("p"),q.textContent=Pe,re=i(),d(Ie.$$.fragment),Xe=i(),d(K.$$.fragment),$e=i(),P=U("p"),P.textContent=Dt},l(M){s=T(M,"P",{"data-svelte-h":!0}),j(s)!=="svelte-10xp4ra"&&(s.textContent=o),n=r(M),m(u.$$.fragment,M),_=r(M),w=T(M,"P",{"data-svelte-h":!0}),j(w)!=="svelte-1epdxoj"&&(w.innerHTML=R),v=r(M),Z=T(M,"P",{"data-svelte-h":!0}),j(Z)!=="svelte-nhehjb"&&(Z.innerHTML=z),k=r(M),m(B.$$.fragment,M),b=r(M),g=T(M,"P",{"data-svelte-h":!0}),j(g)!=="svelte-1dvdug7"&&(g.innerHTML=F),V=r(M),m(C.$$.fragment,M),X=r(M),Q=T(M,"P",{"data-svelte-h":!0}),j(Q)!=="svelte-1t7rb9m"&&(Q.innerHTML=G),$=r(M),m(le.$$.fragment,M),ee=r(M),we=T(M,"P",{"data-svelte-h":!0}),j(we)!=="svelte-12af5vb"&&(we.textContent=Le),te=r(M),m(je.$$.fragment,M),ge=r(M),W=T(M,"P",{"data-svelte-h":!0}),j(W)!=="svelte-i6gmne"&&(W.innerHTML=Ht),Ge=r(M),m(H.$$.fragment,M),De=r(M),ae=T(M,"P",{"data-svelte-h":!0}),j(ae)!=="svelte-1fu1rck"&&(ae.innerHTML=be),Ze=r(M),m(Y.$$.fragment,M),Be=r(M),L=T(M,"P",{"data-svelte-h":!0}),j(L)!=="svelte-16ytijo"&&(L.textContent=qe),se=r(M),m(he.$$.fragment,M),ke=r(M),S=T(M,"P",{"data-svelte-h":!0}),j(S)!=="svelte-dqvp2"&&(S.textContent=Lt),Re=r(M),m(D.$$.fragment,M),Ke=r(M),m(ne.$$.fragment,M),E=r(M),x=T(M,"P",{"data-svelte-h":!0}),j(x)!=="svelte-yj1sgy"&&(x.innerHTML=ve),ie=r(M),m(fe.$$.fragment,M),ze=r(M),q=T(M,"P",{"data-svelte-h":!0}),j(q)!=="svelte-96p1ml"&&(q.textContent=Pe),re=r(M),m(Ie.$$.fragment,M),Xe=r(M),m(K.$$.fragment,M),$e=r(M),P=T(M,"P",{"data-svelte-h":!0}),j(P)!=="svelte-1b1diss"&&(P.textContent=Dt)},m(M,f){a(M,s,f),a(M,n,f),y(u,M,f),a(M,_,f),a(M,w,f),a(M,v,f),a(M,Z,f),a(M,k,f),y(B,M,f),a(M,b,f),a(M,g,f),a(M,V,f),y(C,M,f),a(M,X,f),a(M,Q,f),a(M,$,f),y(le,M,f),a(M,ee,f),a(M,we,f),a(M,te,f),y(je,M,f),a(M,ge,f),a(M,W,f),a(M,Ge,f),y(H,M,f),a(M,De,f),a(M,ae,f),a(M,Ze,f),y(Y,M,f),a(M,Be,f),a(M,L,f),a(M,se,f),y(he,M,f),a(M,ke,f),a(M,S,f),a(M,Re,f),y(D,M,f),a(M,Ke,f),y(ne,M,f),a(M,E,f),a(M,x,f),a(M,ie,f),y(fe,M,f),a(M,ze,f),a(M,q,f),a(M,re,f),y(Ie,M,f),a(M,Xe,f),y(K,M,f),a(M,$e,f),a(M,P,f),We=!0},i(M){We||(p(u.$$.fragment,M),p(B.$$.fragment,M),p(C.$$.fragment,M),p(le.$$.fragment,M),p(je.$$.fragment,M),p(H.$$.fragment,M),p(Y.$$.fragment,M),p(he.$$.fragment,M),p(D.$$.fragment,M),p(ne.$$.fragment,M),p(fe.$$.fragment,M),p(Ie.$$.fragment,M),p(K.$$.fragment,M),We=!0)},o(M){c(u.$$.fragment,M),c(B.$$.fragment,M),c(C.$$.fragment,M),c(le.$$.fragment,M),c(je.$$.fragment,M),c(H.$$.fragment,M),c(Y.$$.fragment,M),c(he.$$.fragment,M),c(D.$$.fragment,M),c(ne.$$.fragment,M),c(fe.$$.fragment,M),c(Ie.$$.fragment,M),c(K.$$.fragment,M),We=!1},d(M){M&&(t(s),t(n),t(_),t(w),t(v),t(Z),t(k),t(b),t(g),t(V),t(X),t(Q),t($),t(ee),t(we),t(te),t(ge),t(W),t(Ge),t(De),t(ae),t(Ze),t(Be),t(L),t(se),t(ke),t(S),t(Re),t(Ke),t(E),t(x),t(ie),t(ze),t(q),t(re),t(Xe),t($e),t(P)),J(u,M),J(B,M),J(C,M),J(le,M),J(je,M),J(H,M),J(Y,M),J(he,M),J(D,M),J(ne,M),J(fe,M),J(Ie,M),J(K,M)}}}function Ai(I){let s,o='✏️ <strong>Încercați!</strong> Pentru a cuantifica beneficiile adaptării domeniului, faceți fine-tune unui clasificator pe labelurile IMDb atât pentru checkpointurile DistilBERT preantrenate, cât și pentru cele fine-tuned. Dacă aveți nevoie de o recapitulare a clasificării textului, consultați <a href="/course/chapter3">Capitolul 3</a>.';return{c(){s=U("p"),s.innerHTML=o},l(n){s=T(n,"P",{"data-svelte-h":!0}),j(s)!=="svelte-1wijmsj"&&(s.innerHTML=o)},m(n,u){a(n,s,u)},p:He,d(n){n&&t(s)}}}function Ni(I){let s,o,n,u,_,w,R,v,Z,z,k,B,b,g,F="Pentru multe aplicații NLP care implică modele Transformer, puteți lua pur și simplu un model preantrenat de pe Hugging Face Hub și să îl faceți fine-tune direct pe datele voastre pentru sarcina dată. Cu condiția că corpusul utilizat pentru preantrenare să nu fie prea diferit de corpusul utilizat pentru fine-tuning, învățarea prin transfer va produce de obicei rezultate bune.",V,C,X="Cu toate acestea, există câteva cazuri în care veți dori să faceți fine-tune mai întâi modelelor lingvistice pe datele voastre, înainte de a antrena un head specific sarcinii. De exemplu, dacă datasetul vostru conține contracte juridice sau articole științifice, un model Transformer obișnuit, precum BERT, va trata de obicei cuvintele specifice domeniului din corpus ca pe niște tokeni rari, iar performanța rezultată poate fi mai puțin satisfăcătoare. Prin fine-tuningul  modelului lingvistic pe baza datelor din domeniu, puteți crește performanța multor sarcini, ceea ce înseamnă că, de obicei, trebuie să efectuați acest pas o singură dată!",Q,G,$='Acest proces de fine-tuning a unui model lingvistic preantrenat pe date din domeniu se numește de obicei <em>adaptare la domeniu</em>. Acesta a fost popularizat în 2018 de <a href="https://arxiv.org/abs/1801.06146" rel="nofollow">ULMFiT</a>, care a fost una dintre primele arhitecturi neuronale (bazate pe LSTM-uri) care a făcut ca învățarea prin transfer să funcționeze cu adevărat pentru NLP. Un exemplu de adaptare la domeniu cu ULMFiT este prezentat în imaginea de mai jos; în această secțiune vom face ceva similar, dar cu un Transformer în loc de un LSTM!',le,ee,we='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/ulmfit.svg" alt="ULMFiT."/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/ulmfit-dark.svg" alt="ULMFiT."/>',Le,te,je='Până la sfârșitul acestei secțiuni, veți avea un <a href="https://huggingface.co/huggingface-course/distilbert-base-uncased-finetuned-imdb?text=This+is+a+great+%5BMASK%5D." rel="nofollow">model de limbaj mascat</a> pe Hub, care poate completa automat propoziții, după cum se poate vedea mai jos:',ge,W,Ht,Ge,H,De="Hai să începem!",ae,be,Ze,Y,Be,L,qe,se,he='Pentru a începe, să alegem un model preantrenat adecvat pentru modelarea limbajului mascat. După cum se vede în următoarea captură de ecran, puteți găsi o listă de candidați prin aplicarea filtrului “Fill-Mask” pe <a href="https://huggingface.co/models?pipeline_tag=fill-mask&amp;sort=downloads" rel="nofollow">Hugging Face Hub</a>:',ke,S,Lt='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter7/mlm-models.png" alt="Hub models." width="80%"/>',Re,D,Ke=`Deși modelele din familia BERT și RoBERTa sunt cele mai descărcate, vom utiliza un model numit <a href="https://huggingface.co/distilbert-base-uncased" rel="nofollow">DistilBERT</a>
care poate fi antrenat mult mai rapid, cu o pierdere mică sau nulă a performanței în aval. Acest model a fost antrenat folosind o tehnică specială numită <a href="https://en.wikipedia.org/wiki/Knowledge_distillation" rel="nofollow"><em>knowledge distillation</em></a>, în care un “model profesor” mare, precum BERT, este folosit pentru a ghida antrenarea unui “model elev” care are mult mai puțini parametrii. O explicație a detaliilor privind distilarea cunoștințelor ne-ar duce prea departe în această secțiune, dar dacă ești interesat, poți citi totul despre aceasta în <a href="https://www.oreilly.com/library/view/natural-language-processing/9781098136789/" rel="nofollow"><em>Natural Language Processing with Transformers</em></a> (cunoscut sub numele colocvial de Transformers textbooks).`,ne,E,x,ve,ie,fe="Cu aproximativ 67 de milioane de parametri, DistilBERT este de aproximativ două ori mai mic decât modelul de bază BERT, ceea ce se traduce aproximativ printr-o creștere de două ori a vitezei de antrenare - super! Să vedem acum ce tipuri de tokeni prezice acest model ca fiind cele mai probabile completări ale unui mic sample de text:",ze,q,Pe,re,Ie='Ca oameni, ne putem imagina multe posibilități pentru tokenul <code>[MASK]</code>, cum ar fi “day”, “ride” sau “painting”. Pentru modelele preantrenate, predicțiile depind de corpusul pe care modelul a fost antrenat, deoarece acesta învață să detecteze tiparele statistice prezente în date. La fel ca BERT, DistilBERT a fost preantrenat pe dataseturile <a href="https://huggingface.co/datasets/wikipedia" rel="nofollow">English Wikipedia</a> și <a href="https://huggingface.co/datasets/bookcorpus" rel="nofollow">BookCorpus</a>, astfel încât ne așteptăm ca predicțiile pentru <code>[MASK]</code> să reflecte aceste domenii. Pentru a prezice masca, avem nevoie de tokenizerul DistilBERT pentru a produce inputurile pentru model, deci hai să-l descărcăm și pe acesta din Hub:',Xe,K,$e,P,Dt="Cu un tokenizer și un model, putem acum să transmitem exemplul nostru de text modelului, să extragem logiturile și să tipărim primii 5 candidați:",We,M,f,Vt,Oe,Kt,el,Es="Putem vedea din rezultate că predicțiile modelului se referă la termeni din viața de zi cu zi, ceea ce poate că nu este surprinzător având în vedere fundamentul Wikipedia în limba engleză. Să vedem cum putem schimba acest domeniu în ceva puțin mai nișat - recenzii de filme foarte polarizate!",Pt,ll,Ot,tl,Hs='Pentru a prezenta adaptarea la domeniu, vom utiliza faimosul [Large Movie Review Dataset] (<a href="https://huggingface.co/datasets/imdb" rel="nofollow">https://huggingface.co/datasets/imdb</a>) (sau IMDb pe scurt), care este un corpus de recenzii de filme care este adesea utilizat pentru a evalua modelele de analiză a sentimentelor. Prin fine-tuningul aplicat asupra DistilBERT pe acest corpus, ne așteptăm ca modelul de limbaj să își adapteze vocabularul de la datele factuale din Wikipedia pe care a fost antrenat în prealabil la elementele mai subiective ale recenziilor de film. Putem obține datele din Hugging Face Hub cu funcția <code>load_dataset()</code> din 🤗 Datasets:',ea,al,la,sl,ta,nl,Ls="Putem vedea că segmentele <code>train</code> și <code>test</code> conțin fiecare 25.000 de recenzii, în timp ce există un segment fără label numită <code>unsupervised</code> care conține 50.000 de recenzii. Să aruncăm o privire la câteva sampleuri pentru a ne face o idee despre tipul de text cu care avem de-a face. Așa cum am făcut în capitolele anterioare ale cursului, vom combina funcțiile <code>Dataset.shuffle()</code> și <code>Dataset.select()</code> pentru a crea un sample aleatoriu:",aa,il,sa,rl,na,Ml,Ds="Da, acestea sunt cu siguranță recenzii de film și, dacă sunteți suficient de bătrâni, ați putea chiar înțelege comentariul din ultima recenzie despre deținerea unei versiuni VHS 😜! Deși nu vom avea nevoie de labeluri pentru modelarea limbajului, putem vedea deja că un <code>0</code> denotă o recenzie negativă, în timp ce un <code>1</code> corespunde uneia pozitive.",ia,Ve,ra,pl,qs='Acum că am aruncat o privire rapidă asupra datelor, să ne apucăm să le pregătim pentru modelarea limbajului mascat. După cum vom vedea, există câteva etape suplimentare pe care trebuie să le parcurgem în comparație cu sarcinile de clasificare a secvențelor pe care le-am văzut în <a href="/course/chapter3">Capitolul 3</a>. Să începem!',Ma,cl,pa,ul,ca,ol,Ks="Atât pentru auto-regressive cât și pentru masked language modeling, un pas comun de preprocesare este concatenarea tuturor exemplelor și apoi împărțirea întregului corpus în bucăți de dimensiuni egale. Acest lucru este destul de diferit de abordarea noastră obișnuită, în care pur și simplu tokenizăm exemplele individuale. De ce să concatenăm totul împreună? Motivul este că exemplele individuale ar putea fi trunchiate dacă sunt prea lungi, ceea ce ar duce la pierderea de informații care ar putea fi utile pentru sarcina de modelare a limbajului!",ua,dl,Ps='Deci, pentru a începe, vom tokeniza mai întâi corpusul nostru ca de obicei, dar <em>fără</em> a seta opțiunea <code>truncation=True</code> în tokenizerul nostru. De asemenea, vom prelua ID-urile cuvintelor dacă acestea sunt disponibile (ceea ce va fi cazul dacă folosim un tokenizer rapid, așa cum este descris în <a href="/course/chapter6/3">Capitolul 6</a>), deoarece vom avea nevoie de ele mai târziu pentru a face mascarea întregului cuvânt. Vom include acest lucru într-o funcție simplă și, în același timp, vom elimina coloanele <code>text</code> și <code>label</code>, deoarece nu mai avem nevoie de ele:',oa,ml,da,yl,ma,Jl,Os="Deoarece DistilBERT este un model de tip BERT, putem vedea că textele codate constau din <code>input_ids</code> și <code>attention_mask</code> pe care le-am văzut în alte capitole, precum și din <code>word_ids</code> pe care le-am adăugat.",ya,Ul,en="Acum că am tokenizat recenziile de filme, următorul pas este să le grupăm pe toate și să împărțim rezultatul în chunkuri. Dar cât de mari ar trebui să fie aceste chunkuri? Acest lucru va fi determinat în cele din urmă de cantitatea de memorie GPU pe care o aveți disponibilă, dar un bun punct de plecare este să vedeți care este dimensiunea maximă a contextului modelului. Aceasta poate fi dedusă prin inspectarea atributului <code>model_max_length</code> al tokenizerului:",Ja,Tl,Ua,wl,Ta,jl,ln="Această valoare este derivată din fișierul <em>tokenizer_config.json</em> asociat cu un checkpoint; în acest caz putem vedea că dimensiunea contextului este de 512 tokeni, la fel ca în cazul BERT.",wa,xe,ja,bl,tn="Prin urmare, pentru a derula experimentele pe GPU-uri precum cele de pe Google Colab, vom alege ceva mai mic care să încapă în memorie:",ba,hl,ha,Ae,fa,fl,an="Acum vine partea distractivă. Pentru a arăta cum funcționează concatenarea, să luăm câteva recenzii din setul nostru de antrenare tokenizat și să imprimăm numărul de tokeni per recenzie:",Ia,Il,Ca,Cl,_a,_l,sn="Putem apoi concatena toate aceste exemple cu un dictionary comprehension, după cum urmează:",ga,gl,Ga,Gl,Za,Zl,nn="Minunat, lungimea totală se verifică - așa că acum să împărțim recenziile concatenate în chunkuri de dimensiunea dată de <code>chunk_size</code>. Pentru a face acest lucru, iterăm peste caracteristicile din <code>concatenated_examples</code> și folosim un list comprehension pentru a crea slice-uri ale fiecărei caracteristici. Rezultatul este un dicționar de chunkuri pentru fiecare caracteristică:",Ba,Bl,ka,kl,Ra,Rl,rn="După cum puteți vedea în acest exemplu, ultimul fragment va fi în general mai mic decât dimensiunea maximă a fragmentului. Există două strategii principale pentru a face față acestei situații:",va,vl,Mn="<li>Aruncați ultimul chunk dacă este mai mic decât <code>chunk_size</code>.</li> <li>Faceți padding ultimului chunk până când lungimea sa este egală cu <code>chunk_size</code>.</li>",za,zl,pn="Vom adopta prima abordare aici, așa că hai să încorporăm toată logica de mai sus într-o singură funcție pe care o putem aplica dataseturilor tokenizate:",Xa,Xl,$a,$l,cn="Observați că în ultimul pas al <code>group_texts()</code> creăm o nouă coloană <code>labels</code> care este o copie a coloanei <code>input_ids</code>. După cum vom vedea în curând, acest lucru se datorează faptului că în modelarea limbajului mascat obiectivul este de a prezice tokeni mascați aleatoriu în input batch, iar prin crearea unei coloane <code>labels</code> furnizăm adevărul de bază din care modelul nostru de limbaj poate să învețe.",Wa,Wl,un="Să aplicăm acum funcția <code>group_texts()</code> dataseturilor tokenizate folosind funcția noastră de încredere <code>Dataset.map()</code>:",Va,Vl,xa,xl,Aa,Al,on="Puteți vedea că gruparea și apoi fragmentarea textelor a produs mult mai multe exemple decât cele 25.000 inițiale pentru spliturile <code>train</code> și <code>test</code>. Acest lucru se datorează faptului că acum avem exemple care implică <em>contigous tokens</em> care se întind pe mai multe exemple din corpusul original. Puteți vedea acest lucru în mod explicit căutând tokenii speciali <code>[SEP]</code> și <code>[CLS]</code> într-unul dintre chunkuri:",Na,Nl,Qa,Ql,Fa,Fl,dn="În acest exemplu puteți vedea două recenzii de film care se suprapun, una despre un film de liceu și cealaltă despre persoanele fără adăpost. Să verificăm, de asemenea, cum arată labelurile pentru modelarea limbajului mascat:",Ya,Yl,Sa,Sl,Ea,El,mn="Așa cum era de așteptat de la funcția noastră <code>group_texts()</code> de mai sus, acest lucru pare identic cu <code>input_ids</code> decodificat - dar atunci cum poate modelul nostru să învețe ceva? Ne lipsește un pas cheie: inserarea tokenilor <code>[MASK]</code> în poziții aleatorii în inputuri! Să vedem cum putem face acest lucru din mers, în timpul fine-tuningului, folosind un data collator special.",Ha,Hl,La,Ll,yn='Fine-tuningul unui model lingvistic mascat este aproape identic cu fine-tuningul a unui model de clasificare a secvențelor, așa cum am făcut în <a href="/course/chapter3">Capitolul 3</a>. Singura diferență este că avem nevoie de un data collator care poate masca aleatoriu o parte dintre tokeni din fiecare batch de texte. Din fericire, 🤗 Transformers vine pregătit cu un <code>DataCollatorForLanguageModeling</code> dedicat tocmai pentru această sarcină. Trebuie doar să îi transmitem tokenizerul și un argument <code>mlm_probability</code> care specifică ce fracțiune din tokeni trebuie mascată. Vom alege 15%, care este cantitatea utilizată pentru BERT și o alegere comună în literatura de specialitate:',Da,Dl,qa,ql,Jn="Pentru a vedea cum funcționează mascarea aleatorie, să introducem câteva exemple în data collator. Deoarece se așteaptă la o listă de “dict”-uri, în care fiecare “dict” reprezintă un singur chunk de text continuu, mai întâi iterăm peste dataset înainte de a trimite batchul către data collator. Eliminăm cheia <code>&quot;word_ids&quot;</code> pentru acest data collator, deoarece acesta nu o așteaptă:",Ka,Kl,Pa,Pl,Oa,Ol,Un="Frumos, a funcționat! Putem vedea că tokenul <code>[MASK]</code> a fost inserat aleatoriu în diferite locuri din textul nostru. Acestea vor fi tokenii pe care modelul nostru va trebui să le prezică în timpul antrenamentului - iar frumusețea data collatorului este că va introduce aleatoriu tokenul <code>[MASK]</code> cu fiecare batch!",es,Ne,ls,xt,et,Tn="La antrenarea modelelor pentru modelarea limbajului mascat, o tehnică care poate fi utilizată este mascarea cuvintelor întregi împreună, nu doar a tokenilor individuali. Această abordare se numește <em>whole word masking</em>. Dacă dorim să utilizăm mascarea întregului cuvânt, va trebui să construim noi înșine un data collator. Un data collator este doar o funcție care preia o listă de sampleuri și le convertește într-un batch, așa că hai să facem asta acum! Vom utiliza ID-urile cuvintelor calculate mai devreme pentru a realiza o hartă între indicii cuvintelor și tokenii corespunzători, apoi vom decide aleatoriu ce cuvinte să mascăm și vom aplica masca respectivă asupra inputurilor. Rețineți că labelurile sunt toate <code>-100</code>, cu excepția celor care corespund cuvintelor mascate.",ts,Me,pe,At,lt,wn="În continuare, îl putem încerca pe aceleași sampleuri ca înainte:",as,tt,ss,at,ns,Qe,is,st,jn='Acum, că avem două data collators, restul pașilor fine-tuning sunt standard. Pregătirea poate dura ceva timp pe Google Colab dacă nu sunteți suficient de norocos să obțineți un GPU P100 mitic 😭, așa că vom reduce mai întâi dimensiunea setului de antrenare la câteva mii de exemple. Nu vă faceți griji, vom obține în continuare un model lingvistic destul de decent! O modalitate rapidă de a reduce sampleurile unui dataset în 🤗 Datasets este prin intermediul funcției <code>Dataset.train_test_split()</code> pe care am văzut-o în <a href="/course/chapter5">Capitolul 5</a>:',rs,nt,Ms,it,ps,rt,bn="Acest lucru a creat în mod automat noi splituri de <code>train</code> și <code>test</code>, cu dimensiunea setului de antrenare setată la 10.000 de exemple și a setului de validare la 10% din aceasta - nu ezitați să măriți această valoare dacă aveți un GPU puternic! Următorul lucru pe care trebuie să îl facem este să ne conectăm la Hugging Face Hub. Dacă executați acest cod într-un notebook, puteți face acest lucru cu următoarea funcție utilitară:",cs,Mt,us,pt,hn="care va afișa un widget în care vă puteți introduce credențialele. Alternativ, puteți rula:",os,ct,ds,ut,fn="in your favorite terminal and log in there.",ms,ce,ue,Nt,ot,ys,dt,Js,mt,In="Spre deosebire de alte sarcini, cum ar fi clasificarea textului sau răspunderea la întrebări, unde ni se oferă un corpus labeled pe care să antrenăm, cu modelarea limbajului nu avem labeluri explicite. Așadar, cum determinăm ce face un model lingvistic bun? La fel ca în cazul funcției de autocorectare din telefon, un model lingvistic bun este unul care atribuie probabilități ridicate propozițiilor corecte din punct de vedere gramatical și probabilități scăzute propozițiilor fără sens. Pentru a vă face o idee mai bună despre cum arată acest lucru, puteți găsi online seturi întregi de “autocorrect fails”, în care modelul din telefonul unei persoane a produs niște completări destul de amuzante (și adesea nepotrivite)!",Us,oe,de,Qt,yt,Ts,Jt,Cn="Un scor de perplexitate mai mic înseamnă un model lingvistic mai bun, iar aici putem vedea că modelul nostru inițial are o valoare oarecum mare. Să vedem dacă o putem reduce prin fine-tuning! Pentru a face acest lucru, vom rula mai întâi bucla de antrenare:",ws,me,ye,Ft,Ut,_n="și apoi calculați perplexitatea rezultată pe setul de testare ca înainte:",js,Je,Ue,Yt,Tt,bs,wt,gn="Grozav - aceasta este o reducere destul de mare a perplexității, ceea ce ne spune că modelul a învățat ceva despre domeniul recenziilor de filme!",hs,St,Fe,fs,Et,jt,Is,bt,Gn="Puteți interacționa cu modelul vostru fine-tuned utilizând widgetul său de pe Hub, fie local cu <code>pipeline</code> din 🤗 Transformers. Să folosim aceasta din urmă pentru a descărca modelul nostru folosind pipelineuul <code>fill-mask</code>:",Cs,ht,_s,ft,Zn="Putem apoi să alimentăm pipelineul cu exemplul nostru de text “This is a hrea [MASK]” și să vedem care sunt primele 5 predicții:",gs,It,Gs,Ct,Zs,_t,Bn="Frumos - modelul nostru și-a adaptat în mod clar weighturile pentru a prezice cuvintele care sunt asociate mai puternic cu filmele!",Bs,gt,ks,Gt,kn='Acest lucru încheie primul nostru experiment de antrenare a unui model lingvistic. În <a href="/course/ro/chapter7/6">secțiunea 6</a> veți învăța cum să antrenați de la zero un model auto-regressive precum GPT-2; mergeți acolo dacă doriți să vedeți cum vă puteți preantrena propriul model Transformer!',Rs,Ye,vs,Zt,zs,qt,Xs;_=new Ji({props:{fw:I[0]}}),R=new mi({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),Z=new Ee({props:{title:"Fine-tuningul la un masked language model",local:"fine-tuning-a-masked-language-model",headingTag:"h1"}});const Rn=[Ti,Ui],Bt=[];function vn(e,l){return e[0]==="pt"?0:1}k=vn(I),B=Bt[k]=Rn[k](I),be=new $s({props:{id:"mqElG5QJWUg"}}),Y=new Se({props:{$$slots:{default:[wi]},$$scope:{ctx:I}}}),L=new Ee({props:{title:"Alegerea unui model preantrenat pentru masked language modeling",local:"picking-a-pretrained-model-for-masked-language-modeling",headingTag:"h2"}});const zn=[bi,ji],kt=[];function Xn(e,l){return e[0]==="pt"?0:1}E=Xn(I),x=kt[E]=zn[E](I),q=new h({props:{code:"dGV4dCUyMCUzRCUyMCUyMlRoaXMlMjBpcyUyMGElMjBncmVhdCUyMCU1Qk1BU0slNUQuJTIy",highlighted:'text = <span class="hljs-string">&quot;This is a great [MASK].&quot;</span>',wrap:!1}}),K=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9jaGVja3BvaW50KQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)`,wrap:!1}});const $n=[fi,hi],Rt=[];function Wn(e,l){return e[0]==="pt"?0:1}M=Wn(I),f=Rt[M]=$n[M](I),Oe=new h({props:{code:"JyUzRSUzRSUzRSUyMFRoaXMlMjBpcyUyMGElMjBncmVhdCUyMGRlYWwuJyUwQSclM0UlM0UlM0UlMjBUaGlzJTIwaXMlMjBhJTIwZ3JlYXQlMjBzdWNjZXNzLiclMEEnJTNFJTNFJTNFJTIwVGhpcyUyMGlzJTIwYSUyMGdyZWF0JTIwYWR2ZW50dXJlLiclMEEnJTNFJTNFJTNFJTIwVGhpcyUyMGlzJTIwYSUyMGdyZWF0JTIwaWRlYS4nJTBBJyUzRSUzRSUzRSUyMFRoaXMlMjBpcyUyMGElMjBncmVhdCUyMGZlYXQuJw==",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; This is a great deal.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; This is a great success.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; This is a great adventure.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; This is a great idea.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; This is a great feat.&#x27;</span>`,wrap:!1}}),ll=new Ee({props:{title:"Datasetul",local:"the-dataset",headingTag:"h2"}}),al=new h({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBaW1kYl9kYXRhc2V0JTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmltZGIlMjIpJTBBaW1kYl9kYXRhc2V0",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

imdb_dataset = load_dataset(<span class="hljs-string">&quot;imdb&quot;</span>)
imdb_dataset`,wrap:!1}}),sl=new h({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ3RleHQnJTJDJTIwJ2xhYmVsJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMjUwMDAlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTIwJTIwJTIwJTIwdGVzdCUzQSUyMERhdGFzZXQoJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZmVhdHVyZXMlM0ElMjAlNUIndGV4dCclMkMlMjAnbGFiZWwnJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjAyNTAwMCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB1bnN1cGVydmlzZWQlM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ3RleHQnJTJDJTIwJ2xhYmVsJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNTAwMDAlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTdEKQ==",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;text&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>],
        num_rows: <span class="hljs-number">25000</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;text&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>],
        num_rows: <span class="hljs-number">25000</span>
    })
    unsupervised: Dataset({
        features: [<span class="hljs-string">&#x27;text&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>],
        num_rows: <span class="hljs-number">50000</span>
    })
})`,wrap:!1}}),il=new h({props:{code:"c2FtcGxlJTIwJTNEJTIwaW1kYl9kYXRhc2V0JTVCJTIydHJhaW4lMjIlNUQuc2h1ZmZsZShzZWVkJTNENDIpLnNlbGVjdChyYW5nZSgzKSklMEElMEFmb3IlMjByb3clMjBpbiUyMHNhbXBsZSUzQSUwQSUyMCUyMCUyMCUyMHByaW50KGYlMjIlNUNuJyUzRSUzRSUzRSUyMFJldmlldyUzQSUyMCU3QnJvdyU1Qid0ZXh0JyU1RCU3RCclMjIpJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiclM0UlM0UlM0UlMjBMYWJlbCUzQSUyMCU3QnJvdyU1QidsYWJlbCclNUQlN0QnJTIyKQ==",highlighted:`sample = imdb_dataset[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>))

<span class="hljs-keyword">for</span> row <span class="hljs-keyword">in</span> sample:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt;&gt; Review: <span class="hljs-subst">{row[<span class="hljs-string">&#x27;text&#x27;</span>]}</span>&#x27;&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; Label: <span class="hljs-subst">{row[<span class="hljs-string">&#x27;label&#x27;</span>]}</span>&#x27;&quot;</span>)`,wrap:!1}}),rl=new h({props:{code:" ",highlighted:`
<span class="hljs-string">&#x27;&gt;&gt;&gt; Review: This is your typical Priyadarshan movie--a bunch of loony characters out on some silly mission. His signature climax has the entire cast of the film coming together and fighting each other in some crazy moshpit over hidden money. Whether it is a winning lottery ticket in Malamaal Weekly, black money in Hera Pheri, &quot;kodokoo&quot; in Phir Hera Pheri, etc., etc., the director is becoming ridiculously predictable. Don\\&#x27;t get me wrong; as clichéd and preposterous his movies may be, I usually end up enjoying the comedy. However, in most his previous movies there has actually been some good humor, (Hungama and Hera Pheri being noteworthy ones). Now, the hilarity of his films is fading as he is using the same formula over and over again.&lt;br /&gt;&lt;br /&gt;Songs are good. Tanushree Datta looks awesome. Rajpal Yadav is irritating, and Tusshar is not a whole lot better. Kunal Khemu is OK, and Sharman Joshi is the best.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Label: 0&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Review: Okay, the story makes no sense, the characters lack any dimensionally, the best dialogue is ad-libs about the low quality of movie, the cinematography is dismal, and only editing saves a bit of the muddle, but Sam&quot; Peckinpah directed the film. Somehow, his direction is not enough. For those who appreciate Peckinpah and his great work, this movie is a disappointment. Even a great cast cannot redeem the time the viewer wastes with this minimal effort.&lt;br /&gt;&lt;br /&gt;The proper response to the movie is the contempt that the director San Peckinpah, James Caan, Robert Duvall, Burt Young, Bo Hopkins, Arthur Hill, and even Gig Young bring to their work. Watch the great Peckinpah films. Skip this mess.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Label: 0&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; Review: I saw this movie at the theaters when I was about 6 or 7 years old. I loved it then, and have recently come to own a VHS version. &lt;br /&gt;&lt;br /&gt;My 4 and 6 year old children love this movie and have been asking again and again to watch it. &lt;br /&gt;&lt;br /&gt;I have enjoyed watching it again too. Though I have to admit it is not as good on a little TV.&lt;br /&gt;&lt;br /&gt;I do not have older children so I do not know what they would think of it. &lt;br /&gt;&lt;br /&gt;The songs are very cute. My daughter keeps singing them over and over.&lt;br /&gt;&lt;br /&gt;Hope this helps.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Label: 1&#x27;</span>`,wrap:!1}}),Ve=new Se({props:{$$slots:{default:[Ii]},$$scope:{ctx:I}}}),cl=new Ee({props:{title:"Preprocesarea datelor",local:"preprocessing-the-data",headingTag:"h2"}}),ul=new $s({props:{id:"8PmhEIXhBvI"}}),ml=new h({props:{code:"ZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwcmVzdWx0JTIwJTNEJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCklMEElMjAlMjAlMjAlMjBpZiUyMHRva2VuaXplci5pc19mYXN0JTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVzdWx0JTVCJTIyd29yZF9pZHMlMjIlNUQlMjAlM0QlMjAlNUJyZXN1bHQud29yZF9pZHMoaSklMjBmb3IlMjBpJTIwaW4lMjByYW5nZShsZW4ocmVzdWx0JTVCJTIyaW5wdXRfaWRzJTIyJTVEKSklNUQlMEElMjAlMjAlMjAlMjByZXR1cm4lMjByZXN1bHQlMEElMEElMEElMjMlMjBVdGlsaXphJUM4JTlCaSUyMGJhdGNoZWQlM0RUcnVlJTIwcGVudHJ1JTIwYSUyMGFjdGl2YSUyMG11bHRpdGhyZWFkaW5ndWwhJTBBdG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwaW1kYl9kYXRhc2V0Lm1hcCglMEElMjAlMjAlMjAlMjB0b2tlbml6ZV9mdW5jdGlvbiUyQyUyMGJhdGNoZWQlM0RUcnVlJTJDJTIwcmVtb3ZlX2NvbHVtbnMlM0QlNUIlMjJ0ZXh0JTIyJTJDJTIwJTIybGFiZWwlMjIlNUQlMEEpJTBBdG9rZW5pemVkX2RhdGFzZXRz",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">examples</span>):
    result = tokenizer(examples[<span class="hljs-string">&quot;text&quot;</span>])
    <span class="hljs-keyword">if</span> tokenizer.is_fast:
        result[<span class="hljs-string">&quot;word_ids&quot;</span>] = [result.word_ids(i) <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-built_in">len</span>(result[<span class="hljs-string">&quot;input_ids&quot;</span>]))]
    <span class="hljs-keyword">return</span> result


<span class="hljs-comment"># Utilizați batched=True pentru a activa multithreadingul!</span>
tokenized_datasets = imdb_dataset.<span class="hljs-built_in">map</span>(
    tokenize_function, batched=<span class="hljs-literal">True</span>, remove_columns=[<span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>]
)
tokenized_datasets`,wrap:!1}}),yl=new h({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpbnB1dF9pZHMnJTJDJTIwJ3dvcmRfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMjUwMDAlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTIwJTIwJTIwJTIwdGVzdCUzQSUyMERhdGFzZXQoJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZmVhdHVyZXMlM0ElMjAlNUInYXR0ZW50aW9uX21hc2snJTJDJTIwJ2lucHV0X2lkcyclMkMlMjAnd29yZF9pZHMnJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjAyNTAwMCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB1bnN1cGVydmlzZWQlM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpbnB1dF9pZHMnJTJDJTIwJ3dvcmRfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNTAwMDAlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTdEKQ==",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">25000</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">25000</span>
    })
    unsupervised: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">50000</span>
    })
})`,wrap:!1}}),Tl=new h({props:{code:"dG9rZW5pemVyLm1vZGVsX21heF9sZW5ndGg=",highlighted:"tokenizer.model_max_length",wrap:!1}}),wl=new h({props:{code:"NTEy",highlighted:'<span class="hljs-number">512</span>',wrap:!1}}),xe=new Se({props:{$$slots:{default:[Ci]},$$scope:{ctx:I}}}),hl=new h({props:{code:"Y2h1bmtfc2l6ZSUyMCUzRCUyMDEyOA==",highlighted:'chunk_size = <span class="hljs-number">128</span>',wrap:!1}}),Ae=new Se({props:{warning:!0,$$slots:{default:[_i]},$$scope:{ctx:I}}}),Il=new h({props:{code:"JTIzJTIwU2xpY2luZ3VsJTIwcHJvZHVjZSUyMG8lMjBsaXN0JUM0JTgzJTIwZGUlMjBsaXN0ZSUyMHBlbnRydSUyMGZpZWNhcmUlMjBjYXJhY3RlcmlzdGljJUM0JTgzJTBBdG9rZW5pemVkX3NhbXBsZXMlMjAlM0QlMjB0b2tlbml6ZWRfZGF0YXNldHMlNUIlMjJ0cmFpbiUyMiU1RCU1QiUzQTMlNUQlMEElMEFmb3IlMjBpZHglMkMlMjBzYW1wbGUlMjBpbiUyMGVudW1lcmF0ZSh0b2tlbml6ZWRfc2FtcGxlcyU1QiUyMmlucHV0X2lkcyUyMiU1RCklM0ElMEElMjAlMjAlMjAlMjBwcmludChmJTIyJyUzRSUzRSUzRSUyMFJldmlldyUyMCU3QmlkeCU3RCUyMGxlbmd0aCUzQSUyMCU3QmxlbihzYW1wbGUpJTdEJyUyMik=",highlighted:`<span class="hljs-comment"># Slicingul produce o listă de liste pentru fiecare caracteristică</span>
tokenized_samples = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][:<span class="hljs-number">3</span>]

<span class="hljs-keyword">for</span> idx, sample <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(tokenized_samples[<span class="hljs-string">&quot;input_ids&quot;</span>]):
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; Review <span class="hljs-subst">{idx}</span> length: <span class="hljs-subst">{<span class="hljs-built_in">len</span>(sample)}</span>&#x27;&quot;</span>)`,wrap:!1}}),Cl=new h({props:{code:"JyUzRSUzRSUzRSUyMFJldmlldyUyMDAlMjBsZW5ndGglM0ElMjAyMDAnJTBBJyUzRSUzRSUzRSUyMFJldmlldyUyMDElMjBsZW5ndGglM0ElMjA1NTknJTBBJyUzRSUzRSUzRSUyMFJldmlldyUyMDIlMjBsZW5ndGglM0ElMjAxOTIn",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; Review 0 length: 200&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Review 1 length: 559&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Review 2 length: 192&#x27;</span>`,wrap:!1}}),gl=new h({props:{code:"Y29uY2F0ZW5hdGVkX2V4YW1wbGVzJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwayUzQSUyMHN1bSh0b2tlbml6ZWRfc2FtcGxlcyU1QmslNUQlMkMlMjAlNUIlNUQpJTIwZm9yJTIwayUyMGluJTIwdG9rZW5pemVkX3NhbXBsZXMua2V5cygpJTBBJTdEJTBBdG90YWxfbGVuZ3RoJTIwJTNEJTIwbGVuKGNvbmNhdGVuYXRlZF9leGFtcGxlcyU1QiUyMmlucHV0X2lkcyUyMiU1RCklMEFwcmludChmJTIyJyUzRSUzRSUzRSUyMENvbmNhdGVuYXRlZCUyMHJldmlld3MlMjBsZW5ndGglM0ElMjAlN0J0b3RhbF9sZW5ndGglN0QnJTIyKQ==",highlighted:`concatenated_examples = {
    k: <span class="hljs-built_in">sum</span>(tokenized_samples[k], []) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> tokenized_samples.keys()
}
total_length = <span class="hljs-built_in">len</span>(concatenated_examples[<span class="hljs-string">&quot;input_ids&quot;</span>])
<span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; Concatenated reviews length: <span class="hljs-subst">{total_length}</span>&#x27;&quot;</span>)`,wrap:!1}}),Gl=new h({props:{code:"JyUzRSUzRSUzRSUyMENvbmNhdGVuYXRlZCUyMHJldmlld3MlMjBsZW5ndGglM0ElMjA5NTEn",highlighted:'<span class="hljs-string">&#x27;&gt;&gt;&gt; Concatenated reviews length: 951&#x27;</span>',wrap:!1}}),Bl=new h({props:{code:"Y2h1bmtzJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwayUzQSUyMCU1QnQlNUJpJTIwJTNBJTIwaSUyMCUyQiUyMGNodW5rX3NpemUlNUQlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwdG90YWxfbGVuZ3RoJTJDJTIwY2h1bmtfc2l6ZSklNUQlMEElMjAlMjAlMjAlMjBmb3IlMjBrJTJDJTIwdCUyMGluJTIwY29uY2F0ZW5hdGVkX2V4YW1wbGVzLml0ZW1zKCklMEElN0QlMEElMEFmb3IlMjBjaHVuayUyMGluJTIwY2h1bmtzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiclM0UlM0UlM0UlMjBDaHVuayUyMGxlbmd0aCUzQSUyMCU3QmxlbihjaHVuayklN0QnJTIyKQ==",highlighted:`chunks = {
    k: [t[i : i + chunk_size] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, total_length, chunk_size)]
    <span class="hljs-keyword">for</span> k, t <span class="hljs-keyword">in</span> concatenated_examples.items()
}

<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> chunks[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&#x27;&gt;&gt;&gt; Chunk length: <span class="hljs-subst">{<span class="hljs-built_in">len</span>(chunk)}</span>&#x27;&quot;</span>)`,wrap:!1}}),kl=new h({props:{code:"JyUzRSUzRSUzRSUyMENodW5rJTIwbGVuZ3RoJTNBJTIwMTI4JyUwQSclM0UlM0UlM0UlMjBDaHVuayUyMGxlbmd0aCUzQSUyMDEyOCclMEEnJTNFJTNFJTNFJTIwQ2h1bmslMjBsZW5ndGglM0ElMjAxMjgnJTBBJyUzRSUzRSUzRSUyMENodW5rJTIwbGVuZ3RoJTNBJTIwMTI4JyUwQSclM0UlM0UlM0UlMjBDaHVuayUyMGxlbmd0aCUzQSUyMDEyOCclMEEnJTNFJTNFJTNFJTIwQ2h1bmslMjBsZW5ndGglM0ElMjAxMjgnJTBBJyUzRSUzRSUzRSUyMENodW5rJTIwbGVuZ3RoJTNBJTIwMTI4JyUwQSclM0UlM0UlM0UlMjBDaHVuayUyMGxlbmd0aCUzQSUyMDU1Jw==",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; Chunk length: 128&#x27;</span>
<span class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QSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGslM0ElMjAlNUJ0JTVCaSUyMCUzQSUyMGklMjAlMkIlMjBjaHVua19zaXplJTVEJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMCUyQyUyMHRvdGFsX2xlbmd0aCUyQyUyMGNodW5rX3NpemUpJTVEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwayUyQyUyMHQlMjBpbiUyMGNvbmNhdGVuYXRlZF9leGFtcGxlcy5pdGVtcygpJTBBJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIzJTIwQ3JlYSVDOCU5QmklMjBvJTIwbm91JUM0JTgzJTIwY29sb2FuJUM0JTgzJTIwZGUlMjBsYWJlbHVyaSUwQSUyMCUyMCUyMCUyMHJlc3VsdCU1QiUyMmxhYmVscyUyMiU1RCUyMCUzRCUyMHJlc3VsdCU1QiUyMmlucHV0X2lkcyUyMiU1RC5jb3B5KCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjByZXN1bHQ=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">group_texts</span>(<span class="hljs-params">examples</span>):
    <span class="hljs-comment"># Concatenarea tuturor textelor</span>
    concatenated_examples = {k: <span class="hljs-built_in">sum</span>(examples[k], []) <span class="hljs-keyword">for</span> k <span class="hljs-keyword">in</span> examples.keys()}
    <span class="hljs-comment"># Calcularea lungimii textelor concatenate</span>
    total_length = <span class="hljs-built_in">len</span>(concatenated_examples[<span class="hljs-built_in">list</span>(examples.keys())[<span class="hljs-number">0</span>]])
    <span class="hljs-comment"># Renunțăm la ultimul chunk dacă este mai mic decât chunk_size</span>
    total_length = (total_length // chunk_size) * chunk_size
    <span class="hljs-comment"># Împărțiți pe bucăți de max_len</span>
    result = {
        k: [t[i : i + chunk_size] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, total_length, chunk_size)]
        <span class="hljs-keyword">for</span> k, t <span class="hljs-keyword">in</span> concatenated_examples.items()
    }
    <span class="hljs-comment"># Creați o nouă coloană de labeluri</span>
    result[<span class="hljs-string">&quot;labels&quot;</span>] = result[<span class="hljs-string">&quot;input_ids&quot;</span>].copy()
    <span class="hljs-keyword">return</span> result`,wrap:!1}}),Vl=new h({props:{code:"bG1fZGF0YXNldHMlMjAlM0QlMjB0b2tlbml6ZWRfZGF0YXNldHMubWFwKGdyb3VwX3RleHRzJTJDJTIwYmF0Y2hlZCUzRFRydWUpJTBBbG1fZGF0YXNldHM=",highlighted:`lm_datasets = tokenized_datasets.<span class="hljs-built_in">map</span>(group_texts, batched=<span class="hljs-literal">True</span>)
lm_datasets`,wrap:!1}}),xl=new h({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpbnB1dF9pZHMnJTJDJTIwJ2xhYmVscyclMkMlMjAnd29yZF9pZHMnJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjA2MTI4OSUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB0ZXN0JTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidhdHRlbnRpb25fbWFzayclMkMlMjAnaW5wdXRfaWRzJyUyQyUyMCdsYWJlbHMnJTJDJTIwJ3dvcmRfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNTk5MDUlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTIwJTIwJTIwJTIwdW5zdXBlcnZpc2VkJTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidhdHRlbnRpb25fbWFzayclMkMlMjAnaW5wdXRfaWRzJyUyQyUyMCdsYWJlbHMnJTJDJTIwJ3dvcmRfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMTIyOTYzJTBBJTIwJTIwJTIwJTIwJTdEKSUwQSU3RCk=",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">61289</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">59905</span>
    })
    unsupervised: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">122963</span>
    })
})`,wrap:!1}}),Nl=new h({props:{code:"dG9rZW5pemVyLmRlY29kZShsbV9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVEJTVCMSU1RCU1QiUyMmlucHV0X2lkcyUyMiU1RCk=",highlighted:'tokenizer.decode(lm_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;input_ids&quot;</span>])',wrap:!1}}),Ql=new h({props:{code:"JTIyLi4uLiUyMGF0Li4uLi4uLi4uLiUyMGhpZ2guJTIwYSUyMGNsYXNzaWMlMjBsaW5lJTIwJTNBJTIwaW5zcGVjdG9yJTIwJTNBJTIwaSdtJTIwaGVyZSUyMHRvJTIwc2FjayUyMG9uZSUyMG9mJTIweW91ciUyMHRlYWNoZXJzLiUyMHN0dWRlbnQlMjAlM0ElMjB3ZWxjb21lJTIwdG8lMjBicm9td2VsbCUyMGhpZ2guJTIwaSUyMGV4cGVjdCUyMHRoYXQlMjBtYW55JTIwYWR1bHRzJTIwb2YlMjBteSUyMGFnZSUyMHRoaW5rJTIwdGhhdCUyMGJyb213ZWxsJTIwaGlnaCUyMGlzJTIwZmFyJTIwZmV0Y2hlZC4lMjB3aGF0JTIwYSUyMHBpdHklMjB0aGF0JTIwaXQlMjBpc24ndCElMjAlNUJTRVAlNUQlMjAlNUJDTFMlNUQlMjBob21lbGVzc25lc3MlMjAoJTIwb3IlMjBob3VzZWxlc3NuZXNzJTIwYXMlMjBnZW9yZ2UlMjBjYXJsaW4lMjBzdGF0ZWQlMjApJTIwaGFzJTIwYmVlbiUyMGFuJTIwaXNzdWUlMjBmb3IlMjB5ZWFycyUyMGJ1dCUyMG5ldmVyJTIwYSUyMHBsYW4lMjB0byUyMGhlbHAlMjB0aG9zZSUyMG9uJTIwdGhlJTIwc3RyZWV0JTIwdGhhdCUyMHdlcmUlMjBvbmNlJTIwY29uc2lkZXJlZCUyMGh1bWFuJTIwd2hvJTIwZGlkJTIwZXZlcnl0aGluZyUyMGZyb20lMjBnb2luZyUyMHRvJTIwc2Nob29sJTJDJTIwd29yayUyQyUyMG9yJTIwdm90ZSUyMGZvciUyMHRoZSUyMG1hdHRlci4lMjBtb3N0JTIwcGVvcGxlJTIwdGhpbmslMjBvZiUyMHRoZSUyMGhvbWVsZXNzJTIy",highlighted:'<span class="hljs-string">&quot;.... at.......... high. a classic line : inspector : i&#x27;m here to sack one of your teachers. student : welcome to bromwell high. i expect that many adults of my age think that bromwell high is far fetched. what a pity that it isn&#x27;t! [SEP] [CLS] homelessness ( or houselessness as george carlin stated ) has been an issue for years but never a plan to help those on the street that were once considered human who did everything from going to school, work, or vote for the matter. most people think of the homeless&quot;</span>',wrap:!1}}),Yl=new h({props:{code:"dG9rZW5pemVyLmRlY29kZShsbV9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVEJTVCMSU1RCU1QiUyMmxhYmVscyUyMiU1RCk=",highlighted:'tokenizer.decode(lm_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-number">1</span>][<span class="hljs-string">&quot;labels&quot;</span>])',wrap:!1}}),Sl=new h({props:{code:"JTIyLi4uLiUyMGF0Li4uLi4uLi4uLiUyMGhpZ2guJTIwYSUyMGNsYXNzaWMlMjBsaW5lJTIwJTNBJTIwaW5zcGVjdG9yJTIwJTNBJTIwaSdtJTIwaGVyZSUyMHRvJTIwc2FjayUyMG9uZSUyMG9mJTIweW91ciUyMHRlYWNoZXJzLiUyMHN0dWRlbnQlMjAlM0ElMjB3ZWxjb21lJTIwdG8lMjBicm9td2VsbCUyMGhpZ2guJTIwaSUyMGV4cGVjdCUyMHRoYXQlMjBtYW55JTIwYWR1bHRzJTIwb2YlMjBteSUyMGFnZSUyMHRoaW5rJTIwdGhhdCUyMGJyb213ZWxsJTIwaGlnaCUyMGlzJTIwZmFyJTIwZmV0Y2hlZC4lMjB3aGF0JTIwYSUyMHBpdHklMjB0aGF0JTIwaXQlMjBpc24ndCElMjAlNUJTRVAlNUQlMjAlNUJDTFMlNUQlMjBob21lbGVzc25lc3MlMjAoJTIwb3IlMjBob3VzZWxlc3NuZXNzJTIwYXMlMjBnZW9yZ2UlMjBjYXJsaW4lMjBzdGF0ZWQlMjApJTIwaGFzJTIwYmVlbiUyMGFuJTIwaXNzdWUlMjBmb3IlMjB5ZWFycyUyMGJ1dCUyMG5ldmVyJTIwYSUyMHBsYW4lMjB0byUyMGhlbHAlMjB0aG9zZSUyMG9uJTIwdGhlJTIwc3RyZWV0JTIwdGhhdCUyMHdlcmUlMjBvbmNlJTIwY29uc2lkZXJlZCUyMGh1bWFuJTIwd2hvJTIwZGlkJTIwZXZlcnl0aGluZyUyMGZyb20lMjBnb2luZyUyMHRvJTIwc2Nob29sJTJDJTIwd29yayUyQyUyMG9yJTIwdm90ZSUyMGZvciUyMHRoZSUyMG1hdHRlci4lMjBtb3N0JTIwcGVvcGxlJTIwdGhpbmslMjBvZiUyMHRoZSUyMGhvbWVsZXNzJTIy",highlighted:'<span class="hljs-string">&quot;.... at.......... high. a classic line : inspector : i&#x27;m here to sack one of your teachers. student : welcome to bromwell high. i expect that many adults of my age think that bromwell high is far fetched. what a pity that it isn&#x27;t! [SEP] [CLS] homelessness ( or houselessness as george carlin stated ) has been an issue for years but never a plan to help those on the street that were once considered human who did everything from going to school, work, or vote for the matter. most people think of the homeless&quot;</span>',wrap:!1}}),Hl=new Ee({props:{title:"Fine-tuningul asupra DistilBERT cu API-ul Trainer",local:"fine-tuning-distilbert-with-the-trainer-api",headingTag:"h2"}}),Dl=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvckZvckxhbmd1YWdlTW9kZWxpbmclMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGF0YUNvbGxhdG9yRm9yTGFuZ3VhZ2VNb2RlbGluZyh0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMjBtbG1fcHJvYmFiaWxpdHklM0QwLjE1KQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorForLanguageModeling

data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm_probability=<span class="hljs-number">0.15</span>)`,wrap:!1}}),Kl=new h({props:{code:"c2FtcGxlcyUyMCUzRCUyMCU1QmxtX2RhdGFzZXRzJTVCJTIydHJhaW4lMjIlNUQlNUJpJTVEJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMiklNUQlMEFmb3IlMjBzYW1wbGUlMjBpbiUyMHNhbXBsZXMlM0ElMEElMjAlMjAlMjAlMjBfJTIwJTNEJTIwc2FtcGxlLnBvcCglMjJ3b3JkX2lkcyUyMiklMEElMEFmb3IlMjBjaHVuayUyMGluJTIwZGF0YV9jb2xsYXRvcihzYW1wbGVzKSU1QiUyMmlucHV0X2lkcyUyMiU1RCUzQSUwQSUyMCUyMCUyMCUyMHByaW50KGYlMjIlNUNuJyUzRSUzRSUzRSUyMCU3QnRva2VuaXplci5kZWNvZGUoY2h1bmspJTdEJyUyMik=",highlighted:`samples = [lm_datasets[<span class="hljs-string">&quot;train&quot;</span>][i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">2</span>)]
<span class="hljs-keyword">for</span> sample <span class="hljs-keyword">in</span> samples:
    _ = sample.pop(<span class="hljs-string">&quot;word_ids&quot;</span>)

<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> data_collator(samples)[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt;&gt; <span class="hljs-subst">{tokenizer.decode(chunk)}</span>&#x27;&quot;</span>)`,wrap:!1}}),Pl=new h({props:{code:"JyUzRSUzRSUzRSUyMCU1QkNMUyU1RCUyMGJyb213ZWxsJTIwJTVCTUFTSyU1RCUyMGlzJTIwYSUyMGNhcnRvb24lMjBjb21lZHkuJTIwaXQlMjByYW4lMjBhdCUyMHRoZSUyMHNhbWUlMjAlNUJNQVNLJTVEJTIwYXMlMjBzb21lJTIwb3RoZXIlMjAlNUJNQVNLJTVEJTIwYWJvdXQlMjBzY2hvb2wlMjBsaWZlJTJDJTIwJTVCTUFTSyU1RCUyMGFzJTIwJTIyJTIwdGVhY2hlcnMlMjAlMjIuJTIwJTVCTUFTSyU1RCUyMCU1Qk1BU0slNUQlMjAlNUJNQVNLJTVEJTIwaW4lMjB0aGUlMjB0ZWFjaGluZyUyMCU1Qk1BU0slNUQlMjBsZWFkJTIwJTVCTUFTSyU1RCUyMHRvJTIwYmVsaWV2ZSUyM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vbmUlMjBvZiUyMHlvdXIlMjAlNUJNQVNLJTVELiUyMHN0dWRlbnQlMjAlM0ElMjB3ZWxjb21lJTIwdG8lMjBicm9td2VsbCUyMCU1Qk1BU0slNUQuJTIwaSUyMGV4cGVjdCUyMHRoYXQlMjBtYW55JTIwYWR1bHRzJTIwb2YlMjBteSUyMGFnZSUyMHRoaW5rJTIwdGhhdCUyMCU1Qk1BU0slNURtd2VsbCUyMCU1Qk1BU0slNUQlMjBpcyUyMCU1Qk1BU0slNUQlMjBmZXRjaGVkLiUyMHdoYXQlMjBhJTIwcGl0eSUyMHRoYXQlMjBpdCUyMGlzbiU1Qyd0ISUyMCU1QlNFUCU1RCUyMCU1QkNMUyU1RCUyMCU1Qk1BU0slNURuZXNzJTIwKCUyMG9yJTIwJTVCTUFTSyU1RGxlc3NuZXNzJTIwYXMlMjBnZW9yZ2UlMjAlRTUlQUUlODdpbiUyMHN0YXRlZCUyMCklRTUlODUlQUMlMjBiZWVuJTIwYW4lMjBpc3N1ZSUyMGZvciUyMHllYXJzJTIwYnV0JTIwbmV2ZXIlMjAlNUJNQVNLJTVEJTIwcGxhbiUyMHRvJTIwaGVscCUyMHRob3NlJTIwb24lMjB0aGUlMjBzdHJlZXQlMjB0aGF0JTIwd2VyZSUyMG9uY2UlMjBjb25zaWRlcmVkJTIwaHVtYW4lMjAlNUJNQVNLJTVEJTIwZGlkJTIwZXZlcnl0aGluZyUyMGZyb20lMjBnb2luZyUyMHRvJTIwc2Nob29sJTJDJTIwJTVCTUFTSyU1RCUyQyUyMCU1Qk1BU0slNUQlMjB2b3RlJTIwZm9yJTIwdGhlJTIwbWF0dGVyLiUyMG1vc3QlMjBwZW9wbGUlMjB0aGluayUyMCU1Qk1BU0slNUQlMjB0aGUlMjBob21lbGVzcyc=",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; [CLS] bromwell [MASK] is a cartoon comedy. it ran at the same [MASK] as some other [MASK] about school life, [MASK] as &quot; teachers &quot;. [MASK] [MASK] [MASK] in the teaching [MASK] lead [MASK] to believe that bromwell high\\&#x27;[MASK] satire is much closer to reality than is &quot; teachers &quot;. the scramble [MASK] [MASK] financially, the [MASK]ful students whogn [MASK] right through [MASK] pathetic teachers\\&#x27;pomp, the pettiness of the whole situation, distinction remind me of the schools i knew and their students. when i saw [MASK] episode in [MASK] a student repeatedly tried to burn down the school, [MASK] immediately recalled. [MASK]...&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; .... at.. [MASK]... [MASK]... high. a classic line plucked inspector : i\\&#x27;[MASK] here to [MASK] one of your [MASK]. student : welcome to bromwell [MASK]. i expect that many adults of my age think that [MASK]mwell [MASK] is [MASK] fetched. what a pity that it isn\\&#x27;t! [SEP] [CLS] [MASK]ness ( or [MASK]lessness as george 宇in stated )公 been an issue for years but never [MASK] plan to help those on the street that were once considered human [MASK] did everything from going to school, [MASK], [MASK] vote for the matter. most people think [MASK] the homeless&#x27;</span>`,wrap:!1}}),Ne=new Se({props:{$$slots:{default:[gi]},$$scope:{ctx:I}}});let O=I[0]==="pt"&&ai();const Vn=[Zi,Gi],vt=[];function xn(e,l){return e[0]==="pt"?0:1}Me=xn(I),pe=vt[Me]=Vn[Me](I),tt=new h({props:{code:"c2FtcGxlcyUyMCUzRCUyMCU1QmxtX2RhdGFzZXRzJTVCJTIydHJhaW4lMjIlNUQlNUJpJTVEJTIwZm9yJTIwaSUyMGluJTIwcmFuZ2UoMiklNUQlMEFiYXRjaCUyMCUzRCUyMHdob2xlX3dvcmRfbWFza2luZ19kYXRhX2NvbGxhdG9yKHNhbXBsZXMpJTBBJTBBZm9yJTIwY2h1bmslMjBpbiUyMGJhdGNoJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiU1Q24nJTNFJTNFJTNFJTIwJTdCdG9rZW5pemVyLmRlY29kZShjaHVuayklN0QnJTIyKQ==",highlighted:`samples = [lm_datasets[<span class="hljs-string">&quot;train&quot;</span>][i] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">2</span>)]
batch = whole_word_masking_data_collator(samples)

<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> batch[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;\\n&#x27;&gt;&gt;&gt; <span class="hljs-subst">{tokenizer.decode(chunk)}</span>&#x27;&quot;</span>)`,wrap:!1}}),at=new h({props:{code:"JyUzRSUzRSUzRSUyMCU1QkNMUyU1RCUyMGJyb213ZWxsJTIwaGlnaCUyMGlzJTIwYSUyMGNhcnRvb24lMjBjb21lZHklMjAlNUJNQVNLJTVEJTIwaXQlMjByYW4lMjBhdCUyMHRoZSUyMHNhbWUlMjB0aW1lJTIwYXMlMjBzb21lJTIwb3RoZXIlMjBwcm9ncmFtcyUyMGFib3V0JTIwc2Nob29sJTIwbGlmZSUyQyUyMHN1Y2glMjBhcyUyMCUyMiUyMHRlYWNoZXJzJTIwJTIyLiUyMG15JTIwMzUlMjB5ZWFycyUyMGluJTIwdGhlJTIwdGVhY2hpbmclMjBwcm9mZXNzaW9uJTIwbGVhZCUyMG1lJTIwdG8lMjBiZWxpZXZlJTIwdGhhdCUyMGJyb213ZWxsJTIwaGlnaCU1QydzJTIwc2F0aXJlJTIwaXMlMjBtdWNoJTIwY2xvc2VyJTIwdG8lMjByZWFsaXR5JTIwdGhhbiUyMGlzJTIwJTIyJTIwdGVhY2hlcnMlMjAlMjIuJTIwdGhlJTIwc2NyYW1ibGUlMjB0byUyMHN1cnZpdmUlMjBmaW5hbmNpYWxseSUyQyUyMHRoZSUyMGluc2lnaHRmdWwlMjBzdHVkZW50cyUyMHdobyUyMGNhbiUyMHNlZSUyMHJpZ2h0JTIwdGhyb3VnaCUyMHRoZWlyJTIwcGF0aGV0aWMlMjB0ZWFjaGVycyU1Qydwb21wJTJDJTIwdGhlJTIwcGV0dGluZXNzJ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VhcnMlMjBidXQlMjBuZXZlciUyMGElMjBwbGFuJTIwdG8lMjBoZWxwJTIwdGhvc2UlMjBvbiUyMHRoZSUyMHN0cmVldCUyMHRoYXQlMjB3ZXJlJTIwb25jZSUyMGNvbnNpZGVyZWQlMjBodW1hbiUyMHdobyUyMGRpZCUyMGV2ZXJ5dGhpbmclMjBmcm9tJTIwZ29pbmclMjB0byUyMHNjaG9vbCUyQyUyMHdvcmslMkMlMjBvciUyMHZvdGUlMjBmb3IlMjB0aGUlMjBtYXR0ZXIuJTIwbW9zdCUyMHBlb3BsZSUyMHRoaW5rJTIwb2YlMjB0aGUlMjBob21lbGVzcyc=",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; [CLS] bromwell high is a cartoon comedy [MASK] it ran at the same time as some other programs about school life, such as &quot; teachers &quot;. my 35 years in the teaching profession lead me to believe that bromwell high\\&#x27;s satire is much closer to reality than is &quot; teachers &quot;. the scramble to survive financially, the insightful students who can see right through their pathetic teachers\\&#x27;pomp, the pettiness of the whole situation, all remind me of the schools i knew and their students. when i saw the episode in which a student repeatedly tried to burn down the school, i immediately recalled.....&#x27;</span>

<span class="hljs-string">&#x27;&gt;&gt;&gt; .... [MASK] [MASK] [MASK] [MASK]....... high. a classic line : inspector : i\\&#x27;m here to sack one of your teachers. student : welcome to bromwell high. i expect that many adults of my age think that bromwell high is far fetched. what a pity that it isn\\&#x27;t! [SEP] [CLS] homelessness ( or houselessness as george carlin stated ) has been an issue for years but never a plan to help those on the street that were once considered human who did everything from going to school, work, or vote for the matter. most people think of the homeless&#x27;</span>`,wrap:!1}}),Qe=new Se({props:{$$slots:{default:[Bi]},$$scope:{ctx:I}}}),nt=new h({props:{code:"dHJhaW5fc2l6ZSUyMCUzRCUyMDEwXzAwMCUwQXRlc3Rfc2l6ZSUyMCUzRCUyMGludCgwLjElMjAqJTIwdHJhaW5fc2l6ZSklMEElMEFkb3duc2FtcGxlZF9kYXRhc2V0JTIwJTNEJTIwbG1fZGF0YXNldHMlNUIlMjJ0cmFpbiUyMiU1RC50cmFpbl90ZXN0X3NwbGl0KCUwQSUyMCUyMCUyMCUyMHRyYWluX3NpemUlM0R0cmFpbl9zaXplJTJDJTIwdGVzdF9zaXplJTNEdGVzdF9zaXplJTJDJTIwc2VlZCUzRDQyJTBBKSUwQWRvd25zYW1wbGVkX2RhdGFzZXQ=",highlighted:`train_size = <span class="hljs-number">10_000</span>
test_size = <span class="hljs-built_in">int</span>(<span class="hljs-number">0.1</span> * train_size)

downsampled_dataset = lm_datasets[<span class="hljs-string">&quot;train&quot;</span>].train_test_split(
    train_size=train_size, test_size=test_size, seed=<span class="hljs-number">42</span>
)
downsampled_dataset`,wrap:!1}}),it=new h({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpbnB1dF9pZHMnJTJDJTIwJ2xhYmVscyclMkMlMjAnd29yZF9pZHMnJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3Jvd3MlM0ElMjAxMDAwMCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB0ZXN0JTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidhdHRlbnRpb25fbWFzayclMkMlMjAnaW5wdXRfaWRzJyUyQyUyMCdsYWJlbHMnJTJDJTIwJ3dvcmRfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMTAwMCUwQSUyMCUyMCUyMCUyMCU3RCklMEElN0Qp",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">10000</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;word_ids&#x27;</span>],
        num_rows: <span class="hljs-number">1000</span>
    })
})`,wrap:!1}}),Mt=new h({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBbm90ZWJvb2tfbG9naW4oKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login

notebook_login()`,wrap:!1}}),ct=new h({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:'huggingface-<span class="hljs-keyword">cli</span> login',wrap:!1}});const An=[Ri,ki],zt=[];function Nn(e,l){return e[0]==="tf"?0:1}ce=Nn(I),ue=zt[ce]=An[ce](I),ot=new Ee({props:{title:"Perplexity pentru language models",local:"perplexity-for-language-models",headingTag:"h3"}}),dt=new $s({props:{id:"NURcDHhYe98"}});const Qn=[zi,vi],Xt=[];function Fn(e,l){return e[0]==="pt"?0:1}oe=Fn(I),de=Xt[oe]=Qn[oe](I),yt=new h({props:{code:"UGVycGxleGl0eSUzQSUyMDIxLjc1",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>Perplexity: <span class="hljs-number">21.75</span>',wrap:!1}});const Yn=[$i,Xi],$t=[];function Sn(e,l){return e[0]==="pt"?0:1}me=Sn(I),ye=$t[me]=Yn[me](I);const En=[Vi,Wi],Wt=[];function Hn(e,l){return e[0]==="pt"?0:1}Je=Hn(I),Ue=Wt[Je]=En[Je](I),Tt=new h({props:{code:"UGVycGxleGl0eSUzQSUyMDExLjMy",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>Perplexity: <span class="hljs-number">11.32</span>',wrap:!1}});let A=I[0]==="pt"&&si();Fe=new Se({props:{$$slots:{default:[xi]},$$scope:{ctx:I}}});let N=I[0]==="pt"&&ni();return jt=new Ee({props:{title:"Utilizarea modelului fine-tuned",local:"using-our-fine-tuned-model",headingTag:"h2"}}),ht=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBbWFza19maWxsZXIlMjAlM0QlMjBwaXBlbGluZSglMEElMjAlMjAlMjAlMjAlMjJmaWxsLW1hc2slMjIlMkMlMjBtb2RlbCUzRCUyMmh1Z2dpbmdmYWNlLWNvdXJzZSUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkLWZpbmV0dW5lZC1pbWRiJTIyJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

mask_filler = pipeline(
    <span class="hljs-string">&quot;fill-mask&quot;</span>, model=<span class="hljs-string">&quot;huggingface-course/distilbert-base-uncased-finetuned-imdb&quot;</span>
)`,wrap:!1}}),It=new h({props:{code:"cHJlZHMlMjAlM0QlMjBtYXNrX2ZpbGxlcih0ZXh0KSUwQSUwQWZvciUyMHByZWQlMjBpbiUyMHByZWRzJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMiUzRSUzRSUzRSUyMCU3QnByZWQlNUInc2VxdWVuY2UnJTVEJTdEJTIyKQ==",highlighted:`preds = mask_filler(text)

<span class="hljs-keyword">for</span> pred <span class="hljs-keyword">in</span> preds:
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;&gt;&gt;&gt; <span class="hljs-subst">{pred[<span class="hljs-string">&#x27;sequence&#x27;</span>]}</span>&quot;</span>)`,wrap:!1}}),Ct=new h({props:{code:"JyUzRSUzRSUzRSUyMHRoaXMlMjBpcyUyMGElMjBncmVhdCUyMG1vdmllLiclMEEnJTNFJTNFJTNFJTIwdGhpcyUyMGlzJTIwYSUyMGdyZWF0JTIwZmlsbS4nJTBBJyUzRSUzRSUzRSUyMHRoaXMlMjBpcyUyMGElMjBncmVhdCUyMHN0b3J5LiclMEEnJTNFJTNFJTNFJTIwdGhpcyUyMGlzJTIwYSUyMGdyZWF0JTIwbW92aWVzLiclMEEnJTNFJTNFJTNFJTIwdGhpcyUyMGlzJTIwYSUyMGdyZWF0JTIwY2hhcmFjdGVyLic=",highlighted:`<span class="hljs-string">&#x27;&gt;&gt;&gt; this is a great movie.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; this is a great film.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; this is a great story.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; this is a great movies.&#x27;</span>
<span class="hljs-string">&#x27;&gt;&gt;&gt; this is a great character.&#x27;</span>`,wrap:!1}}),gt=new $s({props:{id:"0Oxphw4Q9fo"}}),Ye=new Se({props:{$$slots:{default:[Ai]},$$scope:{ctx:I}}}),Zt=new yi({props:{source:"https://github.com/huggingface/course/blob/main/chapters/ro/chapter7/3.mdx"}}),{c(){s=U("meta"),o=i(),n=U("p"),u=i(),d(_.$$.fragment),w=i(),d(R.$$.fragment),v=i(),d(Z.$$.fragment),z=i(),B.c(),b=i(),g=U("p"),g.textContent=F,V=i(),C=U("p"),C.textContent=X,Q=i(),G=U("p"),G.innerHTML=$,le=i(),ee=U("div"),ee.innerHTML=we,Le=i(),te=U("p"),te.innerHTML=je,ge=i(),W=U("iframe"),Ge=i(),H=U("p"),H.textContent=De,ae=i(),d(be.$$.fragment),Ze=i(),d(Y.$$.fragment),Be=i(),d(L.$$.fragment),qe=i(),se=U("p"),se.innerHTML=he,ke=i(),S=U("div"),S.innerHTML=Lt,Re=i(),D=U("p"),D.innerHTML=Ke,ne=i(),x.c(),ve=i(),ie=U("p"),ie.textContent=fe,ze=i(),d(q.$$.fragment),Pe=i(),re=U("p"),re.innerHTML=Ie,Xe=i(),d(K.$$.fragment),$e=i(),P=U("p"),P.textContent=Dt,We=i(),f.c(),Vt=i(),d(Oe.$$.fragment),Kt=i(),el=U("p"),el.textContent=Es,Pt=i(),d(ll.$$.fragment),Ot=i(),tl=U("p"),tl.innerHTML=Hs,ea=i(),d(al.$$.fragment),la=i(),d(sl.$$.fragment),ta=i(),nl=U("p"),nl.innerHTML=Ls,aa=i(),d(il.$$.fragment),sa=i(),d(rl.$$.fragment),na=i(),Ml=U("p"),Ml.innerHTML=Ds,ia=i(),d(Ve.$$.fragment),ra=i(),pl=U("p"),pl.innerHTML=qs,Ma=i(),d(cl.$$.fragment),pa=i(),d(ul.$$.fragment),ca=i(),ol=U("p"),ol.textContent=Ks,ua=i(),dl=U("p"),dl.innerHTML=Ps,oa=i(),d(ml.$$.fragment),da=i(),d(yl.$$.fragment),ma=i(),Jl=U("p"),Jl.innerHTML=Os,ya=i(),Ul=U("p"),Ul.innerHTML=en,Ja=i(),d(Tl.$$.fragment),Ua=i(),d(wl.$$.fragment),Ta=i(),jl=U("p"),jl.innerHTML=ln,wa=i(),d(xe.$$.fragment),ja=i(),bl=U("p"),bl.textContent=tn,ba=i(),d(hl.$$.fragment),ha=i(),d(Ae.$$.fragment),fa=i(),fl=U("p"),fl.textContent=an,Ia=i(),d(Il.$$.fragment),Ca=i(),d(Cl.$$.fragment),_a=i(),_l=U("p"),_l.textContent=sn,ga=i(),d(gl.$$.fragment),Ga=i(),d(Gl.$$.fragment),Za=i(),Zl=U("p"),Zl.innerHTML=nn,Ba=i(),d(Bl.$$.fragment),ka=i(),d(kl.$$.fragment),Ra=i(),Rl=U("p"),Rl.textContent=rn,va=i(),vl=U("ul"),vl.innerHTML=Mn,za=i(),zl=U("p"),zl.textContent=pn,Xa=i(),d(Xl.$$.fragment),$a=i(),$l=U("p"),$l.innerHTML=cn,Wa=i(),Wl=U("p"),Wl.innerHTML=un,Va=i(),d(Vl.$$.fragment),xa=i(),d(xl.$$.fragment),Aa=i(),Al=U("p"),Al.innerHTML=on,Na=i(),d(Nl.$$.fragment),Qa=i(),d(Ql.$$.fragment),Fa=i(),Fl=U("p"),Fl.textContent=dn,Ya=i(),d(Yl.$$.fragment),Sa=i(),d(Sl.$$.fragment),Ea=i(),El=U("p"),El.innerHTML=mn,Ha=i(),d(Hl.$$.fragment),La=i(),Ll=U("p"),Ll.innerHTML=yn,Da=i(),d(Dl.$$.fragment),qa=i(),ql=U("p"),ql.innerHTML=Jn,Ka=i(),d(Kl.$$.fragment),Pa=i(),d(Pl.$$.fragment),Oa=i(),Ol=U("p"),Ol.innerHTML=Un,es=i(),d(Ne.$$.fragment),ls=i(),O&&O.c(),xt=i(),et=U("p"),et.innerHTML=Tn,ts=i(),pe.c(),At=i(),lt=U("p"),lt.textContent=wn,as=i(),d(tt.$$.fragment),ss=i(),d(at.$$.fragment),ns=i(),d(Qe.$$.fragment),is=i(),st=U("p"),st.innerHTML=jn,rs=i(),d(nt.$$.fragment),Ms=i(),d(it.$$.fragment),ps=i(),rt=U("p"),rt.innerHTML=bn,cs=i(),d(Mt.$$.fragment),us=i(),pt=U("p"),pt.textContent=hn,os=i(),d(ct.$$.fragment),ds=i(),ut=U("p"),ut.textContent=fn,ms=i(),ue.c(),Nt=i(),d(ot.$$.fragment),ys=i(),d(dt.$$.fragment),Js=i(),mt=U("p"),mt.textContent=In,Us=i(),de.c(),Qt=i(),d(yt.$$.fragment),Ts=i(),Jt=U("p"),Jt.textContent=Cn,ws=i(),ye.c(),Ft=i(),Ut=U("p"),Ut.textContent=_n,js=i(),Ue.c(),Yt=i(),d(Tt.$$.fragment),bs=i(),wt=U("p"),wt.textContent=gn,hs=i(),A&&A.c(),St=i(),d(Fe.$$.fragment),fs=i(),N&&N.c(),Et=i(),d(jt.$$.fragment),Is=i(),bt=U("p"),bt.innerHTML=Gn,Cs=i(),d(ht.$$.fragment),_s=i(),ft=U("p"),ft.textContent=Zn,gs=i(),d(It.$$.fragment),Gs=i(),d(Ct.$$.fragment),Zs=i(),_t=U("p"),_t.textContent=Bn,Bs=i(),d(gt.$$.fragment),ks=i(),Gt=U("p"),Gt.innerHTML=kn,Rs=i(),d(Ye.$$.fragment),vs=i(),d(Zt.$$.fragment),zs=i(),qt=U("p"),this.h()},l(e){const l=oi("svelte-u9bgzb",document.head);s=T(l,"META",{name:!0,content:!0}),l.forEach(t),o=r(e),n=T(e,"P",{}),Ss(n).forEach(t),u=r(e),m(_.$$.fragment,e),w=r(e),m(R.$$.fragment,e),v=r(e),m(Z.$$.fragment,e),z=r(e),B.l(e),b=r(e),g=T(e,"P",{"data-svelte-h":!0}),j(g)!=="svelte-1glyo4x"&&(g.textContent=F),V=r(e),C=T(e,"P",{"data-svelte-h":!0}),j(C)!=="svelte-9afh7"&&(C.textContent=X),Q=r(e),G=T(e,"P",{"data-svelte-h":!0}),j(G)!=="svelte-f8z56n"&&(G.innerHTML=$),le=r(e),ee=T(e,"DIV",{class:!0,"data-svelte-h":!0}),j(ee)!=="svelte-1lvgpuv"&&(ee.innerHTML=we),Le=r(e),te=T(e,"P",{"data-svelte-h":!0}),j(te)!=="svelte-1ks0ykh"&&(te.innerHTML=je),ge=r(e),W=T(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),Ss(W).forEach(t),Ge=r(e),H=T(e,"P",{"data-svelte-h":!0}),j(H)!=="svelte-zrrr7l"&&(H.textContent=De),ae=r(e),m(be.$$.fragment,e),Ze=r(e),m(Y.$$.fragment,e),Be=r(e),m(L.$$.fragment,e),qe=r(e),se=T(e,"P",{"data-svelte-h":!0}),j(se)!=="svelte-19tpmhb"&&(se.innerHTML=he),ke=r(e),S=T(e,"DIV",{class:!0,"data-svelte-h":!0}),j(S)!=="svelte-zc90xi"&&(S.innerHTML=Lt),Re=r(e),D=T(e,"P",{"data-svelte-h":!0}),j(D)!=="svelte-t3m32n"&&(D.innerHTML=Ke),ne=r(e),x.l(e),ve=r(e),ie=T(e,"P",{"data-svelte-h":!0}),j(ie)!=="svelte-1uazy4q"&&(ie.textContent=fe),ze=r(e),m(q.$$.fragment,e),Pe=r(e),re=T(e,"P",{"data-svelte-h":!0}),j(re)!=="svelte-1q0eyba"&&(re.innerHTML=Ie),Xe=r(e),m(K.$$.fragment,e),$e=r(e),P=T(e,"P",{"data-svelte-h":!0}),j(P)!=="svelte-1wiyj16"&&(P.textContent=Dt),We=r(e),f.l(e),Vt=r(e),m(Oe.$$.fragment,e),Kt=r(e),el=T(e,"P",{"data-svelte-h":!0}),j(el)!=="svelte-1hnwm2v"&&(el.textContent=Es),Pt=r(e),m(ll.$$.fragment,e),Ot=r(e),tl=T(e,"P",{"data-svelte-h":!0}),j(tl)!=="svelte-12bkabn"&&(tl.innerHTML=Hs),ea=r(e),m(al.$$.fragment,e),la=r(e),m(sl.$$.fragment,e),ta=r(e),nl=T(e,"P",{"data-svelte-h":!0}),j(nl)!=="svelte-j1i9tv"&&(nl.innerHTML=Ls),aa=r(e),m(il.$$.fragment,e),sa=r(e),m(rl.$$.fragment,e),na=r(e),Ml=T(e,"P",{"data-svelte-h":!0}),j(Ml)!=="svelte-hkwtqx"&&(Ml.innerHTML=Ds),ia=r(e),m(Ve.$$.fragment,e),ra=r(e),pl=T(e,"P",{"data-svelte-h":!0}),j(pl)!=="svelte-1m0mhpj"&&(pl.innerHTML=qs),Ma=r(e),m(cl.$$.fragment,e),pa=r(e),m(ul.$$.fragment,e),ca=r(e),ol=T(e,"P",{"data-svelte-h":!0}),j(ol)!=="svelte-hdf18f"&&(ol.textContent=Ks),ua=r(e),dl=T(e,"P",{"data-svelte-h":!0}),j(dl)!=="svelte-lnwk3h"&&(dl.innerHTML=Ps),oa=r(e),m(ml.$$.fragment,e),da=r(e),m(yl.$$.fragment,e),ma=r(e),Jl=T(e,"P",{"data-svelte-h":!0}),j(Jl)!=="svelte-wfbgxq"&&(Jl.innerHTML=Os),ya=r(e),Ul=T(e,"P",{"data-svelte-h":!0}),j(Ul)!=="svelte-17qokwh"&&(Ul.innerHTML=en),Ja=r(e),m(Tl.$$.fragment,e),Ua=r(e),m(wl.$$.fragment,e),Ta=r(e),jl=T(e,"P",{"data-svelte-h":!0}),j(jl)!=="svelte-th3ra0"&&(jl.innerHTML=ln),wa=r(e),m(xe.$$.fragment,e),ja=r(e),bl=T(e,"P",{"data-svelte-h":!0}),j(bl)!=="svelte-1bnf1r0"&&(bl.textContent=tn),ba=r(e),m(hl.$$.fragment,e),ha=r(e),m(Ae.$$.fragment,e),fa=r(e),fl=T(e,"P",{"data-svelte-h":!0}),j(fl)!=="svelte-y17wu1"&&(fl.textContent=an),Ia=r(e),m(Il.$$.fragment,e),Ca=r(e),m(Cl.$$.fragment,e),_a=r(e),_l=T(e,"P",{"data-svelte-h":!0}),j(_l)!=="svelte-cvzlep"&&(_l.textContent=sn),ga=r(e),m(gl.$$.fragment,e),Ga=r(e),m(Gl.$$.fragment,e),Za=r(e),Zl=T(e,"P",{"data-svelte-h":!0}),j(Zl)!=="svelte-1a13xg3"&&(Zl.innerHTML=nn),Ba=r(e),m(Bl.$$.fragment,e),ka=r(e),m(kl.$$.fragment,e),Ra=r(e),Rl=T(e,"P",{"data-svelte-h":!0}),j(Rl)!=="svelte-1a4v5sr"&&(Rl.textContent=rn),va=r(e),vl=T(e,"UL",{"data-svelte-h":!0}),j(vl)!=="svelte-wr64b9"&&(vl.innerHTML=Mn),za=r(e),zl=T(e,"P",{"data-svelte-h":!0}),j(zl)!=="svelte-162vh3a"&&(zl.textContent=pn),Xa=r(e),m(Xl.$$.fragment,e),$a=r(e),$l=T(e,"P",{"data-svelte-h":!0}),j($l)!=="svelte-1anfhnt"&&($l.innerHTML=cn),Wa=r(e),Wl=T(e,"P",{"data-svelte-h":!0}),j(Wl)!=="svelte-1qifxd"&&(Wl.innerHTML=un),Va=r(e),m(Vl.$$.fragment,e),xa=r(e),m(xl.$$.fragment,e),Aa=r(e),Al=T(e,"P",{"data-svelte-h":!0}),j(Al)!=="svelte-3xtpi5"&&(Al.innerHTML=on),Na=r(e),m(Nl.$$.fragment,e),Qa=r(e),m(Ql.$$.fragment,e),Fa=r(e),Fl=T(e,"P",{"data-svelte-h":!0}),j(Fl)!=="svelte-1hlwqy6"&&(Fl.textContent=dn),Ya=r(e),m(Yl.$$.fragment,e),Sa=r(e),m(Sl.$$.fragment,e),Ea=r(e),El=T(e,"P",{"data-svelte-h":!0}),j(El)!=="svelte-crcf21"&&(El.innerHTML=mn),Ha=r(e),m(Hl.$$.fragment,e),La=r(e),Ll=T(e,"P",{"data-svelte-h":!0}),j(Ll)!=="svelte-166bscs"&&(Ll.innerHTML=yn),Da=r(e),m(Dl.$$.fragment,e),qa=r(e),ql=T(e,"P",{"data-svelte-h":!0}),j(ql)!=="svelte-1pbpata"&&(ql.innerHTML=Jn),Ka=r(e),m(Kl.$$.fragment,e),Pa=r(e),m(Pl.$$.fragment,e),Oa=r(e),Ol=T(e,"P",{"data-svelte-h":!0}),j(Ol)!=="svelte-emlzho"&&(Ol.innerHTML=Un),es=r(e),m(Ne.$$.fragment,e),ls=r(e),O&&O.l(e),xt=r(e),et=T(e,"P",{"data-svelte-h":!0}),j(et)!=="svelte-6avu40"&&(et.innerHTML=Tn),ts=r(e),pe.l(e),At=r(e),lt=T(e,"P",{"data-svelte-h":!0}),j(lt)!=="svelte-h1lcm8"&&(lt.textContent=wn),as=r(e),m(tt.$$.fragment,e),ss=r(e),m(at.$$.fragment,e),ns=r(e),m(Qe.$$.fragment,e),is=r(e),st=T(e,"P",{"data-svelte-h":!0}),j(st)!=="svelte-17aj1q6"&&(st.innerHTML=jn),rs=r(e),m(nt.$$.fragment,e),Ms=r(e),m(it.$$.fragment,e),ps=r(e),rt=T(e,"P",{"data-svelte-h":!0}),j(rt)!=="svelte-1wg7gde"&&(rt.innerHTML=bn),cs=r(e),m(Mt.$$.fragment,e),us=r(e),pt=T(e,"P",{"data-svelte-h":!0}),j(pt)!=="svelte-1863eha"&&(pt.textContent=hn),os=r(e),m(ct.$$.fragment,e),ds=r(e),ut=T(e,"P",{"data-svelte-h":!0}),j(ut)!=="svelte-1sc64uc"&&(ut.textContent=fn),ms=r(e),ue.l(e),Nt=r(e),m(ot.$$.fragment,e),ys=r(e),m(dt.$$.fragment,e),Js=r(e),mt=T(e,"P",{"data-svelte-h":!0}),j(mt)!=="svelte-1sjjttb"&&(mt.textContent=In),Us=r(e),de.l(e),Qt=r(e),m(yt.$$.fragment,e),Ts=r(e),Jt=T(e,"P",{"data-svelte-h":!0}),j(Jt)!=="svelte-xn33jc"&&(Jt.textContent=Cn),ws=r(e),ye.l(e),Ft=r(e),Ut=T(e,"P",{"data-svelte-h":!0}),j(Ut)!=="svelte-tizs3m"&&(Ut.textContent=_n),js=r(e),Ue.l(e),Yt=r(e),m(Tt.$$.fragment,e),bs=r(e),wt=T(e,"P",{"data-svelte-h":!0}),j(wt)!=="svelte-1j9d15c"&&(wt.textContent=gn),hs=r(e),A&&A.l(e),St=r(e),m(Fe.$$.fragment,e),fs=r(e),N&&N.l(e),Et=r(e),m(jt.$$.fragment,e),Is=r(e),bt=T(e,"P",{"data-svelte-h":!0}),j(bt)!=="svelte-jjpvfc"&&(bt.innerHTML=Gn),Cs=r(e),m(ht.$$.fragment,e),_s=r(e),ft=T(e,"P",{"data-svelte-h":!0}),j(ft)!=="svelte-iz3i8z"&&(ft.textContent=Zn),gs=r(e),m(It.$$.fragment,e),Gs=r(e),m(Ct.$$.fragment,e),Zs=r(e),_t=T(e,"P",{"data-svelte-h":!0}),j(_t)!=="svelte-d9qtzg"&&(_t.textContent=Bn),Bs=r(e),m(gt.$$.fragment,e),ks=r(e),Gt=T(e,"P",{"data-svelte-h":!0}),j(Gt)!=="svelte-dfc1tg"&&(Gt.innerHTML=kn),Rs=r(e),m(Ye.$$.fragment,e),vs=r(e),m(Zt.$$.fragment,e),zs=r(e),qt=T(e,"P",{}),Ss(qt).forEach(t),this.h()},h(){Te(s,"name","hf:doc:metadata"),Te(s,"content",Qi),Te(ee,"class","flex justify-center"),Mi(W.src,Ht="https://course-demos-distilbert-base-uncased-finetuned-imdb.hf.space")||Te(W,"src",Ht),Te(W,"frameborder","0"),Te(W,"height","300"),Te(W,"title","Gradio app"),Te(W,"class","block dark:hidden container p-0 flex-grow space-iframe"),Te(W,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),Te(W,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),Te(S,"class","flex justify-center")},m(e,l){di(document.head,s),a(e,o,l),a(e,n,l),a(e,u,l),y(_,e,l),a(e,w,l),y(R,e,l),a(e,v,l),y(Z,e,l),a(e,z,l),Bt[k].m(e,l),a(e,b,l),a(e,g,l),a(e,V,l),a(e,C,l),a(e,Q,l),a(e,G,l),a(e,le,l),a(e,ee,l),a(e,Le,l),a(e,te,l),a(e,ge,l),a(e,W,l),a(e,Ge,l),a(e,H,l),a(e,ae,l),y(be,e,l),a(e,Ze,l),y(Y,e,l),a(e,Be,l),y(L,e,l),a(e,qe,l),a(e,se,l),a(e,ke,l),a(e,S,l),a(e,Re,l),a(e,D,l),a(e,ne,l),kt[E].m(e,l),a(e,ve,l),a(e,ie,l),a(e,ze,l),y(q,e,l),a(e,Pe,l),a(e,re,l),a(e,Xe,l),y(K,e,l),a(e,$e,l),a(e,P,l),a(e,We,l),Rt[M].m(e,l),a(e,Vt,l),y(Oe,e,l),a(e,Kt,l),a(e,el,l),a(e,Pt,l),y(ll,e,l),a(e,Ot,l),a(e,tl,l),a(e,ea,l),y(al,e,l),a(e,la,l),y(sl,e,l),a(e,ta,l),a(e,nl,l),a(e,aa,l),y(il,e,l),a(e,sa,l),y(rl,e,l),a(e,na,l),a(e,Ml,l),a(e,ia,l),y(Ve,e,l),a(e,ra,l),a(e,pl,l),a(e,Ma,l),y(cl,e,l),a(e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),a(e,Ms,l),y(it,e,l),a(e,ps,l),a(e,rt,l),a(e,cs,l),y(Mt,e,l),a(e,us,l),a(e,pt,l),a(e,os,l),y(ct,e,l),a(e,ds,l),a(e,ut,l),a(e,ms,l),zt[ce].m(e,l),a(e,Nt,l),y(ot,e,l),a(e,ys,l),y(dt,e,l),a(e,Js,l),a(e,mt,l),a(e,Us,l),Xt[oe].m(e,l),a(e,Qt,l),y(yt,e,l),a(e,Ts,l),a(e,Jt,l),a(e,ws,l),$t[me].m(e,l),a(e,Ft,l),a(e,Ut,l),a(e,js,l),Wt[Je].m(e,l),a(e,Yt,l),y(Tt,e,l),a(e,bs,l),a(e,wt,l),a(e,hs,l),A&&A.m(e,l),a(e,St,l),y(Fe,e,l),a(e,fs,l),N&&N.m(e,l),a(e,Et,l),y(jt,e,l),a(e,Is,l),a(e,bt,l),a(e,Cs,l),y(ht,e,l),a(e,_s,l),a(e,ft,l),a(e,gs,l),y(It,e,l),a(e,Gs,l),y(Ct,e,l),a(e,Zs,l),a(e,_t,l),a(e,Bs,l),y(gt,e,l),a(e,ks,l),a(e,Gt,l),a(e,Rs,l),y(Ye,e,l),a(e,vs,l),y(Zt,e,l),a(e,zs,l),a(e,qt,l),Xs=!0},p(e,[l]){const Ln={};l&1&&(Ln.fw=e[0]),_.$set(Ln);let Ws=k;k=vn(e),k!==Ws&&(_e(),c(Bt[Ws],1,1,()=>{Bt[Ws]=null}),Ce(),B=Bt[k],B||(B=Bt[k]=Rn[k](e),B.c()),p(B,1),B.m(b.parentNode,b));const Dn={};l&2&&(Dn.$$scope={dirty:l,ctx:e}),Y.$set(Dn);let Vs=E;E=Xn(e),E!==Vs&&(_e(),c(kt[Vs],1,1,()=>{kt[Vs]=null}),Ce(),x=kt[E],x||(x=kt[E]=zn[E](e),x.c()),p(x,1),x.m(ve.parentNode,ve));let xs=M;M=Wn(e),M!==xs&&(_e(),c(Rt[xs],1,1,()=>{Rt[xs]=null}),Ce(),f=Rt[M],f||(f=Rt[M]=$n[M](e),f.c()),p(f,1),f.m(Vt.parentNode,Vt));const qn={};l&2&&(qn.$$scope={dirty:l,ctx:e}),Ve.$set(qn);const Kn={};l&2&&(Kn.$$scope={dirty:l,ctx:e}),xe.$set(Kn);const Pn={};l&2&&(Pn.$$scope={dirty:l,ctx:e}),Ae.$set(Pn);const On={};l&2&&(On.$$scope={dirty:l,ctx:e}),Ne.$set(On),e[0]==="pt"?O||(O=ai(),O.c(),O.m(xt.parentNode,xt)):O&&(O.d(1),O=null);let As=Me;Me=xn(e),Me!==As&&(_e(),c(vt[As],1,1,()=>{vt[As]=null}),Ce(),pe=vt[Me],pe||(pe=vt[Me]=Vn[Me](e),pe.c()),p(pe,1),pe.m(At.parentNode,At));const ei={};l&2&&(ei.$$scope={dirty:l,ctx:e}),Qe.$set(ei);let Ns=ce;ce=Nn(e),ce!==Ns&&(_e(),c(zt[Ns],1,1,()=>{zt[Ns]=null}),Ce(),ue=zt[ce],ue||(ue=zt[ce]=An[ce](e),ue.c()),p(ue,1),ue.m(Nt.parentNode,Nt));let Qs=oe;oe=Fn(e),oe!==Qs&&(_e(),c(Xt[Qs],1,1,()=>{Xt[Qs]=null}),Ce(),de=Xt[oe],de||(de=Xt[oe]=Qn[oe](e),de.c()),p(de,1),de.m(Qt.parentNode,Qt));let Fs=me;me=Sn(e),me!==Fs&&(_e(),c($t[Fs],1,1,()=>{$t[Fs]=null}),Ce(),ye=$t[me],ye||(ye=$t[me]=Yn[me](e),ye.c()),p(ye,1),ye.m(Ft.parentNode,Ft));let Ys=Je;Je=Hn(e),Je!==Ys&&(_e(),c(Wt[Ys],1,1,()=>{Wt[Ys]=null}),Ce(),Ue=Wt[Je],Ue||(Ue=Wt[Je]=En[Je](e),Ue.c()),p(Ue,1),Ue.m(Yt.parentNode,Yt)),e[0]==="pt"?A?l&1&&p(A,1):(A=si(),A.c(),p(A,1),A.m(St.parentNode,St)):A&&(_e(),c(A,1,1,()=>{A=null}),Ce());const li={};l&2&&(li.$$scope={dirty:l,ctx:e}),Fe.$set(li),e[0]==="pt"?N?l&1&&p(N,1):(N=ni(),N.c(),p(N,1),N.m(Et.parentNode,Et)):N&&(_e(),c(N,1,1,()=>{N=null}),Ce());const ti={};l&2&&(ti.$$scope={dirty:l,ctx:e}),Ye.$set(ti)},i(e){Xs||(p(_.$$.fragment,e),p(R.$$.fragment,e),p(Z.$$.fragment,e),p(B),p(be.$$.fragment,e),p(Y.$$.fragment,e),p(L.$$.fragment,e),p(x),p(q.$$.fragment,e),p(K.$$.fragment,e),p(f),p(Oe.$$.fragment,e),p(ll.$$.fragment,e),p(al.$$.fragment,e),p(sl.$$.fragment,e),p(il.$$.fragment,e),p(rl.$$.fragment,e),p(Ve.$$.fragment,e),p(cl.$$.fragment,e),p(ul.$$.fragment,e),p(ml.$$.fragment,e),p(yl.$$.fragment,e),p(Tl.$$.fragment,e),p(wl.$$.fragment,e),p(xe.$$.fragment,e),p(hl.$$.fragment,e),p(Ae.$$.fragment,e),p(Il.$$.fragment,e),p(Cl.$$.fragment,e),p(gl.$$.fragment,e),p(Gl.$$.fragment,e),p(Bl.$$.fragment,e),p(kl.$$.fragment,e),p(Xl.$$.fragment,e),p(Vl.$$.fragment,e),p(xl.$$.fragment,e),p(Nl.$$.fragment,e),p(Ql.$$.fragment,e),p(Yl.$$.fragment,e),p(Sl.$$.fragment,e),p(Hl.$$.fragment,e),p(Dl.$$.fragment,e),p(Kl.$$.fragment,e),p(Pl.$$.fragment,e),p(Ne.$$.fragment,e),p(pe),p(tt.$$.fragment,e),p(at.$$.fragment,e),p(Qe.$$.fragment,e),p(nt.$$.fragment,e),p(it.$$.fragment,e),p(Mt.$$.fragment,e),p(ct.$$.fragment,e),p(ue),p(ot.$$.fragment,e),p(dt.$$.fragment,e),p(de),p(yt.$$.fragment,e),p(ye),p(Ue),p(Tt.$$.fragment,e),p(A),p(Fe.$$.fragment,e),p(N),p(jt.$$.fragment,e),p(ht.$$.fragment,e),p(It.$$.fragment,e),p(Ct.$$.fragment,e),p(gt.$$.fragment,e),p(Ye.$$.fragment,e),p(Zt.$$.fragment,e),Xs=!0)},o(e){c(_.$$.fragment,e),c(R.$$.fragment,e),c(Z.$$.fragment,e),c(B),c(be.$$.fragment,e),c(Y.$$.fragment,e),c(L.$$.fragment,e),c(x),c(q.$$.fragment,e),c(K.$$.fragment,e),c(f),c(Oe.$$.fragment,e),c(ll.$$.fragment,e),c(al.$$.fragment,e),c(sl.$$.fragment,e),c(il.$$.fragment,e),c(rl.$$.fragment,e),c(Ve.$$.fragment,e),c(cl.$$.fragment,e),c(ul.$$.fragment,e),c(ml.$$.fragment,e),c(yl.$$.fragment,e),c(Tl.$$.fragment,e),c(wl.$$.fragment,e),c(xe.$$.fragment,e),c(hl.$$.fragment,e),c(Ae.$$.fragment,e),c(Il.$$.fragment,e),c(Cl.$$.fragment,e),c(gl.$$.fragment,e),c(Gl.$$.fragment,e),c(Bl.$$.fragment,e),c(kl.$$.fragment,e),c(Xl.$$.fragment,e),c(Vl.$$.fragment,e),c(xl.$$.fragment,e),c(Nl.$$.fragment,e),c(Ql.$$.fragment,e),c(Yl.$$.fragment,e),c(Sl.$$.fragment,e),c(Hl.$$.fragment,e),c(Dl.$$.fragment,e),c(Kl.$$.fragment,e),c(Pl.$$.fragment,e),c(Ne.$$.fragment,e),c(pe),c(tt.$$.fragment,e),c(at.$$.fragment,e),c(Qe.$$.fragment,e),c(nt.$$.fragment,e),c(it.$$.fragment,e),c(Mt.$$.fragment,e),c(ct.$$.fragment,e),c(ue),c(ot.$$.fragment,e),c(dt.$$.fragment,e),c(de),c(yt.$$.fragment,e),c(ye),c(Ue),c(Tt.$$.fragment,e),c(A),c(Fe.$$.fragment,e),c(N),c(jt.$$.fragment,e),c(ht.$$.fragment,e),c(It.$$.fragment,e),c(Ct.$$.fragment,e),c(gt.$$.fragment,e),c(Ye.$$.fragment,e),c(Zt.$$.fragment,e),Xs=!1},d(e){e&&(t(o),t(n),t(u),t(w),t(v),t(z),t(b),t(g),t(V),t(C),t(Q),t(G),t(le),t(ee),t(Le),t(te),t(ge),t(W),t(Ge),t(H),t(ae),t(Ze),t(Be),t(qe),t(se),t(ke),t(S),t(Re),t(D),t(ne),t(ve),t(ie),t(ze),t(Pe),t(re),t(Xe),t($e),t(P),t(We),t(Vt),t(Kt),t(el),t(Pt),t(Ot),t(tl),t(ea),t(la),t(ta),t(nl),t(aa),t(sa),t(na),t(Ml),t(ia),t(ra),t(pl),t(Ma),t(pa),t(ca),t(ol),t(ua),t(dl),t(oa),t(da),t(ma),t(Jl),t(ya),t(Ul),t(Ja),t(Ua),t(Ta),t(jl),t(wa),t(ja),t(bl),t(ba),t(ha),t(fa),t(fl),t(Ia),t(Ca),t(_a),t(_l),t(ga),t(Ga),t(Za),t(Zl),t(Ba),t(ka),t(Ra),t(Rl),t(va),t(vl),t(za),t(zl),t(Xa),t($a),t($l),t(Wa),t(Wl),t(Va),t(xa),t(Aa),t(Al),t(Na),t(Qa),t(Fa),t(Fl),t(Ya),t(Sa),t(Ea),t(El),t(Ha),t(La),t(Ll),t(Da),t(qa),t(ql),t(Ka),t(Pa),t(Oa),t(Ol),t(es),t(ls),t(xt),t(et),t(ts),t(At),t(lt),t(as),t(ss),t(ns),t(is),t(st),t(rs),t(Ms),t(ps),t(rt),t(cs),t(us),t(pt),t(os),t(ds),t(ut),t(ms),t(Nt),t(ys),t(Js),t(mt),t(Us),t(Qt),t(Ts),t(Jt),t(ws),t(Ft),t(Ut),t(js),t(Yt),t(bs),t(wt),t(hs),t(St),t(fs),t(Et),t(Is),t(bt),t(Cs),t(_s),t(ft),t(gs),t(Gs),t(Zs),t(_t),t(Bs),t(ks),t(Gt),t(Rs),t(vs),t(zs),t(qt)),t(s),J(_,e),J(R,e),J(Z,e),Bt[k].d(e),J(be,e),J(Y,e),J(L,e),kt[E].d(e),J(q,e),J(K,e),Rt[M].d(e),J(Oe,e),J(ll,e),J(al,e),J(sl,e),J(il,e),J(rl,e),J(Ve,e),J(cl,e),J(ul,e),J(ml,e),J(yl,e),J(Tl,e),J(wl,e),J(xe,e),J(hl,e),J(Ae,e),J(Il,e),J(Cl,e),J(gl,e),J(Gl,e),J(Bl,e),J(kl,e),J(Xl,e),J(Vl,e),J(xl,e),J(Nl,e),J(Ql,e),J(Yl,e),J(Sl,e),J(Hl,e),J(Dl,e),J(Kl,e),J(Pl,e),J(Ne,e),O&&O.d(e),vt[Me].d(e),J(tt,e),J(at,e),J(Qe,e),J(nt,e),J(it,e),J(Mt,e),J(ct,e),zt[ce].d(e),J(ot,e),J(dt,e),Xt[oe].d(e),J(yt,e),$t[me].d(e),Wt[Je].d(e),J(Tt,e),A&&A.d(e),J(Fe,e),N&&N.d(e),J(jt,e),J(ht,e),J(It,e),J(Ct,e),J(gt,e),J(Ye,e),J(Zt,e)}}}const Qi='{"title":"Fine-tuningul la un masked language model","local":"fine-tuning-a-masked-language-model","sections":[{"title":"Alegerea unui model preantrenat pentru masked language modeling","local":"picking-a-pretrained-model-for-masked-language-modeling","sections":[],"depth":2},{"title":"Datasetul","local":"the-dataset","sections":[],"depth":2},{"title":"Preprocesarea datelor","local":"preprocessing-the-data","sections":[],"depth":2},{"title":"Fine-tuningul asupra DistilBERT cu API-ul Trainer","local":"fine-tuning-distilbert-with-the-trainer-api","sections":[{"title":"Perplexity pentru language models","local":"perplexity-for-language-models","sections":[],"depth":3}],"depth":2},{"title":"Fine-tuningul DistilBERT cu 🤗 Accelerate","local":"fine-tuning-distilbert-with-accelerate","sections":[],"depth":2},{"title":"Utilizarea modelului fine-tuned","local":"using-our-fine-tuned-model","sections":[],"depth":2}],"depth":1}';function Fi(I,s,o){let n="pt";return pi(()=>{const u=new URLSearchParams(window.location.search);o(0,n=u.get("fw")||"pt")}),[n]}class Pi extends ci{constructor(s){super(),ui(this,s,Fi,Ni,ri,{})}}export{Pi as component};
