import{s as ke,o as Ue}from"../chunks/scheduler.37c15a92.js";import{S as xe,i as $e,g as h,s as o,r as J,A as we,h as g,f as n,c as m,j as ge,u as T,x as w,k as ae,y as _e,a as r,v as j,t as d,b as Je,d as M,w as k,m as Ce,n as Ze,p as Te}from"../chunks/index.2bf4358c.js";import{T as We}from"../chunks/Tip.363c041f.js";import{C as A}from"../chunks/CodeBlock.4e987730.js";import{C as je}from"../chunks/CourseFloatingBanner.6add7356.js";import{F as ze}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as ve,E as Ve}from"../chunks/getInferenceSnippets.24b50994.js";function Ne(y){let s,i;return s=new je({props:{chapter:4,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/chapter4/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter4/section2_tf.ipynb"}]}}),{c(){J(s.$$.fragment)},l(a){T(s.$$.fragment,a)},m(a,f){j(s,a,f),i=!0},i(a){i||(M(s.$$.fragment,a),i=!0)},o(a){d(s.$$.fragment,a),i=!1},d(a){k(s,a)}}}function Ee(y){let s,i;return s=new je({props:{chapter:4,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/chapter4/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter4/section2_pt.ipynb"}]}}),{c(){J(s.$$.fragment)},l(a){T(s.$$.fragment,a)},m(a,f){j(s,a,f),i=!0},i(a){i||(M(s.$$.fragment,a),i=!0)},o(a){d(s.$$.fragment,a),i=!1},d(a){k(s,a)}}}function Qe(y){let s,i,a,f='Însă, recomandăm utilizarea <a href="https://huggingface.co/transformers/model_doc/auto?highlight=auto#auto-classes" rel="nofollow">claselor <code>TFAuto*</code></a>, deoarece acestea sunt proiectate să fie architecture-agnostic. În timp ce codul precedent limita utilizatorii la checkpoints loadable în CamemBERT architecture, utilizarea claselor <code>TFAuto*</code> face schimbarea checkpointurilor simplă:',u,p,b;return s=new A({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENhbWVtYmVydFRva2VuaXplciUyQyUyMFRGQ2FtZW1iZXJ0Rm9yTWFza2VkTE0lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBDYW1lbWJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZDYW1lbWJlcnRGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyY2FtZW1iZXJ0LWJhc2UlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CamembertTokenizer, TFCamembertForMaskedLM

tokenizer = CamembertTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = TFCamembertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),p=new A({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyY2FtZW1iZXJ0LWJhc2UlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvck1hc2tlZExNLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = TFAutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),{c(){J(s.$$.fragment),i=o(),a=h("p"),a.innerHTML=f,u=o(),J(p.$$.fragment)},l(t){T(s.$$.fragment,t),i=m(t),a=g(t,"P",{"data-svelte-h":!0}),w(a)!=="svelte-1pw6ztn"&&(a.innerHTML=f),u=m(t),T(p.$$.fragment,t)},m(t,c){j(s,t,c),r(t,i,c),r(t,a,c),r(t,u,c),j(p,t,c),b=!0},i(t){b||(M(s.$$.fragment,t),M(p.$$.fragment,t),b=!0)},o(t){d(s.$$.fragment,t),d(p.$$.fragment,t),b=!1},d(t){t&&(n(i),n(a),n(u)),k(s,t),k(p,t)}}}function Fe(y){let s,i,a,f='Însă, recomandăm utilizarea <a href="https://huggingface.co/transformers/model_doc/auto?highlight=auto#auto-classes" rel="nofollow">claselor <code>Auto*</code></a>, deoarece acestea sunt proiectate să fie architecture-agnostic. În timp ce codul precedent limita utilizatorii la checkpoints loadable în CamemBERT architecture, utilizarea claselor <code>Auto*</code> face schimbarea checkpointurilor simplă:',u,p,b;return s=new A({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENhbWVtYmVydFRva2VuaXplciUyQyUyMENhbWVtYmVydEZvck1hc2tlZExNJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQ2FtZW1iZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMENhbWVtYmVydEZvck1hc2tlZExNLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CamembertTokenizer, CamembertForMaskedLM

tokenizer = CamembertTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = CamembertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),p=new A({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),{c(){J(s.$$.fragment),i=o(),a=h("p"),a.innerHTML=f,u=o(),J(p.$$.fragment)},l(t){T(s.$$.fragment,t),i=m(t),a=g(t,"P",{"data-svelte-h":!0}),w(a)!=="svelte-zilc3z"&&(a.innerHTML=f),u=m(t),T(p.$$.fragment,t)},m(t,c){j(s,t,c),r(t,i,c),r(t,a,c),r(t,u,c),j(p,t,c),b=!0},i(t){b||(M(s.$$.fragment,t),M(p.$$.fragment,t),b=!0)},o(t){d(s.$$.fragment,t),d(p.$$.fragment,t),b=!1},d(t){t&&(n(i),n(a),n(u)),k(s,t),k(p,t)}}}function Be(y){let s;return{c(){s=Ce("În momentul în care folosiți un model preantrenat, asigurați-vă să verificați cum a fost antrenat și pe ce date se bazează. De asemenea, trebuie să cunoasceți limitele și prejudecățile sale. Toată această informație va fi indicată pe cartea modelului.")},l(i){s=Ze(i,"În momentul în care folosiți un model preantrenat, asigurați-vă să verificați cum a fost antrenat și pe ce date se bazează. De asemenea, trebuie să cunoasceți limitele și prejudecățile sale. Toată această informație va fi indicată pe cartea modelului.")},m(i,a){r(i,s,a)},d(i){i&&n(s)}}}function Ie(y){let s,i,a,f,u,p,b,t,c,U,G,W,re="Hubul Model oferă o modalitate simplă de a selecta modelul adecvat, astfel încât utilizarea sa în orice bibliotecă downstream poate fi efectuată în câteva linii de cod. Să vedem cum se utilizează efectiv unul dintre aceste modele și cum putem contribui înapoi la comunitate.",S,z,ie="Să presupunem că noi căutăm un French-based model ce poate face mask filling.",R,_,ce='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/camembert.gif" alt="Selecting the Camembert model." width="80%"/>',L,v,oe="Alegem checkpointul „camembert-base” pentru al încerca. Identificatorul <code>camembert-base</code> este tot de ce avem nevoie pentru a începe. În capitolele precedente, am văzut cum putem inițializa modelul folosind funcția <code>pipeline()</code>:",D,V,H,N,q,E,me="În mod evident, încărcarea unui model într-un pipeline este extrem de simplu. Singurul lucru la care trebuie să atrageți atenția este că checkpointul ales este adecvat pentru sarcina pe care urmează să o execute. De exemplu, în momentul în care încărăm checkpoint-ul „camembert-base” în pipelineul <code>fill-mask</code>, este perfect în regulă. Dar dacă îl încărcam în pipelineul <code>text-classification</code>, rezultatele nu vor avea nici o logică, pentru că headul „camembert-base” nu este adecvat pentru această sarcină! Recomandăm utilizarea task selectorului în interfața Hugging Face în scopul selectării checkpointurilor adecvate:",P,C,pe='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/tasks.png" alt="Selectorul de sarcini pe interfața web." width="80%"/>',K,Q,ue="Puteți inițializa checkpointul în mod direct folosind arhitectura modelului:",O,x,$,Y,Z,ee,F,te,X,se;u=new ze({props:{fw:y[0]}}),b=new ve({props:{title:"Utilizarea modelelor preantrenate",local:"using-pretrained-models",headingTag:"h1"}});const be=[Ee,Ne],B=[];function fe(e,l){return e[0]==="pt"?0:1}c=fe(y),U=B[c]=be[c](y),V=new A({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2FtZW1iZXJ0X2ZpbGxfbWFzayUyMCUzRCUyMHBpcGVsaW5lKCUyMmZpbGwtbWFzayUyMiUyQyUyMG1vZGVsJTNEJTIyY2FtZW1iZXJ0LWJhc2UlMjIpJTBBcmVzdWx0cyUyMCUzRCUyMGNhbWVtYmVydF9maWxsX21hc2soJTIyTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjAlM0NtYXNrJTNFJTIwJTNBKSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

camembert_fill_mask = pipeline(<span class="hljs-string">&quot;fill-mask&quot;</span>, model=<span class="hljs-string">&quot;camembert-base&quot;</span>)
results = camembert_fill_mask(<span class="hljs-string">&quot;Le camembert est &lt;mask&gt; :)&quot;</span>)`,wrap:!1}}),N=new A({props:{code:"JTVCJTBBJTIwJTIwJTdCJ3NlcXVlbmNlJyUzQSUyMCdMZSUyMGNhbWVtYmVydCUyMGVzdCUyMGQlQzMlQTlsaWNpZXV4JTIwJTNBKSclMkMlMjAnc2NvcmUnJTNBJTIwMC40OTA5MTAwNTMyNTMxNzM4MyUyQyUyMCd0b2tlbiclM0ElMjA3MjAwJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnZCVDMyVBOWxpY2lldXgnJTdEJTJDJTIwJTBBJTIwJTIwJTdCJ3NlcXVlbmNlJyUzQSUyMCdMZSUyMGNhbWVtYmVydCUyMGVzdCUyMGV4Y2VsbGVudCUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMTA1NTY5NzQyNjE5OTkxMyUyQyUyMCd0b2tlbiclM0ElMjAyMTgzJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnZXhjZWxsZW50JyU3RCUyQyUyMCUwQSUyMCUyMCU3QidzZXF1ZW5jZSclM0ElMjAnTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjBzdWNjdWxlbnQlMjAlM0EpJyUyQyUyMCdzY29yZSclM0ElMjAwLjAzNDUzMzEzMTg2NzY0NzE3JTJDJTIwJ3Rva2VuJyUzQSUyMDI2MjAyJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnc3VjY3VsZW50JyU3RCUyQyUyMCUwQSUyMCUyMCU3QidzZXF1ZW5jZSclM0ElMjAnTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjBtZWlsbGV1ciUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMDMzMDMxNDExNDY4OTgyNyUyQyUyMCd0b2tlbiclM0ElMjA1MjglMkMlMjAndG9rZW5fc3RyJyUzQSUyMCdtZWlsbGV1ciclN0QlMkMlMjAlMEElMjAlMjAlN0Inc2VxdWVuY2UnJTNBJTIwJ0xlJTIwY2FtZW1iZXJ0JTIwZXN0JTIwcGFyZmFpdCUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMDMwMDc2NTAxODkxMDE2OTYlMkMlMjAndG9rZW4nJTNBJTIwMTY1NCUyQyUyMCd0b2tlbl9zdHInJTNBJTIwJ3BhcmZhaXQnJTdEJTBBJTVE",highlighted:`[
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est délicieux :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.49091005325317383</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">7200</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;délicieux&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est excellent :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.1055697426199913</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">2183</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;excellent&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est succulent :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.03453313186764717</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">26202</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;succulent&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est meilleur :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0330314114689827</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">528</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;meilleur&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est parfait :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.03007650189101696</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">1654</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;parfait&#x27;</span>}
]`,wrap:!1}});const de=[Fe,Qe],I=[];function Me(e,l){return e[0]==="pt"?0:1}return x=Me(y),$=I[x]=de[x](y),Z=new We({props:{$$slots:{default:[Be]},$$scope:{ctx:y}}}),F=new Ve({props:{source:"https://github.com/huggingface/course/blob/main/chapters/rum/chapter4/2.mdx"}}),{c(){s=h("meta"),i=o(),a=h("p"),f=o(),J(u.$$.fragment),p=o(),J(b.$$.fragment),t=o(),U.c(),G=o(),W=h("p"),W.textContent=re,S=o(),z=h("p"),z.textContent=ie,R=o(),_=h("div"),_.innerHTML=ce,L=o(),v=h("p"),v.innerHTML=oe,D=o(),J(V.$$.fragment),H=o(),J(N.$$.fragment),q=o(),E=h("p"),E.innerHTML=me,P=o(),C=h("div"),C.innerHTML=pe,K=o(),Q=h("p"),Q.textContent=ue,O=o(),$.c(),Y=o(),J(Z.$$.fragment),ee=o(),J(F.$$.fragment),te=o(),X=h("p"),this.h()},l(e){const l=we("svelte-u9bgzb",document.head);s=g(l,"META",{name:!0,content:!0}),l.forEach(n),i=m(e),a=g(e,"P",{}),ge(a).forEach(n),f=m(e),T(u.$$.fragment,e),p=m(e),T(b.$$.fragment,e),t=m(e),U.l(e),G=m(e),W=g(e,"P",{"data-svelte-h":!0}),w(W)!=="svelte-ux3m28"&&(W.textContent=re),S=m(e),z=g(e,"P",{"data-svelte-h":!0}),w(z)!=="svelte-18kl4hy"&&(z.textContent=ie),R=m(e),_=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(_)!=="svelte-4k6hvy"&&(_.innerHTML=ce),L=m(e),v=g(e,"P",{"data-svelte-h":!0}),w(v)!=="svelte-1ar3bju"&&(v.innerHTML=oe),D=m(e),T(V.$$.fragment,e),H=m(e),T(N.$$.fragment,e),q=m(e),E=g(e,"P",{"data-svelte-h":!0}),w(E)!=="svelte-14jmibh"&&(E.innerHTML=me),P=m(e),C=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(C)!=="svelte-1855i9v"&&(C.innerHTML=pe),K=m(e),Q=g(e,"P",{"data-svelte-h":!0}),w(Q)!=="svelte-1qchvez"&&(Q.textContent=ue),O=m(e),$.l(e),Y=m(e),T(Z.$$.fragment,e),ee=m(e),T(F.$$.fragment,e),te=m(e),X=g(e,"P",{}),ge(X).forEach(n),this.h()},h(){ae(s,"name","hf:doc:metadata"),ae(s,"content",Ge),ae(_,"class","flex justify-center"),ae(C,"class","flex justify-center")},m(e,l){_e(document.head,s),r(e,i,l),r(e,a,l),r(e,f,l),j(u,e,l),r(e,p,l),j(b,e,l),r(e,t,l),B[c].m(e,l),r(e,G,l),r(e,W,l),r(e,S,l),r(e,z,l),r(e,R,l),r(e,_,l),r(e,L,l),r(e,v,l),r(e,D,l),j(V,e,l),r(e,H,l),j(N,e,l),r(e,q,l),r(e,E,l),r(e,P,l),r(e,C,l),r(e,K,l),r(e,Q,l),r(e,O,l),I[x].m(e,l),r(e,Y,l),j(Z,e,l),r(e,ee,l),j(F,e,l),r(e,te,l),r(e,X,l),se=!0},p(e,[l]){const ye={};l&1&&(ye.fw=e[0]),u.$set(ye);let le=c;c=fe(e),c!==le&&(Te(),d(B[le],1,1,()=>{B[le]=null}),Je(),U=B[c],U||(U=B[c]=be[c](e),U.c()),M(U,1),U.m(G.parentNode,G));let ne=x;x=Me(e),x!==ne&&(Te(),d(I[ne],1,1,()=>{I[ne]=null}),Je(),$=I[x],$||($=I[x]=de[x](e),$.c()),M($,1),$.m(Y.parentNode,Y));const he={};l&2&&(he.$$scope={dirty:l,ctx:e}),Z.$set(he)},i(e){se||(M(u.$$.fragment,e),M(b.$$.fragment,e),M(U),M(V.$$.fragment,e),M(N.$$.fragment,e),M($),M(Z.$$.fragment,e),M(F.$$.fragment,e),se=!0)},o(e){d(u.$$.fragment,e),d(b.$$.fragment,e),d(U),d(V.$$.fragment,e),d(N.$$.fragment,e),d($),d(Z.$$.fragment,e),d(F.$$.fragment,e),se=!1},d(e){e&&(n(i),n(a),n(f),n(p),n(t),n(G),n(W),n(S),n(z),n(R),n(_),n(L),n(v),n(D),n(H),n(q),n(E),n(P),n(C),n(K),n(Q),n(O),n(Y),n(ee),n(te),n(X)),n(s),k(u,e),k(b,e),B[c].d(e),k(V,e),k(N,e),I[x].d(e),k(Z,e),k(F,e)}}}const Ge='{"title":"Utilizarea modelelor preantrenate","local":"using-pretrained-models","sections":[],"depth":1}';function Ye(y,s,i){let a="pt";return Ue(()=>{const f=new URLSearchParams(window.location.search);i(0,a=f.get("fw")||"pt")}),[a]}class qe extends xe{constructor(s){super(),$e(this,s,Ye,Ie,ke,{})}}export{qe as component};
