import{s as Te,o as je}from"../chunks/scheduler.37c15a92.js";import{S as ke,i as Ue,g as h,s as m,r as k,A as xe,h as g,f as n,c as p,j as ye,u as U,x as w,k as se,y as $e,a as r,v as x,t as f,b as he,d as M,w as $,m as we,n as Ce,p as ge}from"../chunks/index.2bf4358c.js";import{T as _e}from"../chunks/Tip.363c041f.js";import{C as Y}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Je}from"../chunks/CourseFloatingBanner.15ba07e6.js";import{F as Ze}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as We}from"../chunks/Heading.8ada512a.js";function Ve(y){let t,o;return t=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/pt/chapter4/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/pt/chapter4/section2_tf.ipynb"}]}}),{c(){k(t.$$.fragment)},l(a){U(t.$$.fragment,a)},m(a,b){x(t,a,b),o=!0},i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){f(t.$$.fragment,a),o=!1},d(a){$(t,a)}}}function ve(y){let t,o;return t=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/pt/chapter4/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/pt/chapter4/section2_pt.ipynb"}]}}),{c(){k(t.$$.fragment)},l(a){U(t.$$.fragment,a)},m(a,b){x(t,a,b),o=!0},i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){f(t.$$.fragment,a),o=!1},d(a){$(t,a)}}}function Ne(y){let t,o,a,b='No entanto, recomendamos a utilização das classes <a href="https://huggingface.co/transformers/model_doc/auto.html?highlight=auto#auto-classes" rel="nofollow"><code>TFAuto*</code></a>, pois estas são por arquitetura de projeto - agnóstica. Enquanto a amostra de código anterior limita os usuários a checkpoint carregáveis na arquitetura CamemBERT, a utilização das classes <code>TFAuto*</code> torna a troca de checkpoint simples:',u,c,d;return t=new Y({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}}),c=new Y({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(){k(t.$$.fragment),o=m(),a=h("p"),a.innerHTML=b,u=m(),k(c.$$.fragment)},l(s){U(t.$$.fragment,s),o=p(s),a=g(s,"P",{"data-svelte-h":!0}),w(a)!=="svelte-3bgiy7"&&(a.innerHTML=b),u=p(s),U(c.$$.fragment,s)},m(s,i){x(t,s,i),r(s,o,i),r(s,a,i),r(s,u,i),x(c,s,i),d=!0},i(s){d||(M(t.$$.fragment,s),M(c.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(c.$$.fragment,s),d=!1},d(s){s&&(n(o),n(a),n(u)),$(t,s),$(c,s)}}}function ze(y){let t,o,a,b='No entanto, recomendamos a utilização das classes <a href="https://huggingface.co/transformers/model_doc/auto.html?highlight=auto#auto-classes" rel="nofollow"><code>Auto*</code></a>, pois estas são por arquitetura de projeto - agnóstica. Enquanto a amostra de código anterior limita os usuários a checkpoint carregáveis na arquitetura CamemBERT, a utilização das classes <code>Auto*</code> torna a troca de checkpoint simples:',u,c,d;return t=new Y({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}}),c=new Y({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(){k(t.$$.fragment),o=m(),a=h("p"),a.innerHTML=b,u=m(),k(c.$$.fragment)},l(s){U(t.$$.fragment,s),o=p(s),a=g(s,"P",{"data-svelte-h":!0}),w(a)!=="svelte-eqgo83"&&(a.innerHTML=b),u=p(s),U(c.$$.fragment,s)},m(s,i){x(t,s,i),r(s,o,i),r(s,a,i),r(s,u,i),x(c,s,i),d=!0},i(s){d||(M(t.$$.fragment,s),M(c.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(c.$$.fragment,s),d=!1},d(s){s&&(n(o),n(a),n(u)),$(t,s),$(c,s)}}}function qe(y){let t;return{c(){t=we("Ao utilizar um modelo pré-treinado, certifique-se de verificar como ele foi treinado, em quais datasets, seus limites e seus enviesamentos. Todas estas informações devem ser indicadas em seu modelo de cartão.")},l(o){t=Ce(o,"Ao utilizar um modelo pré-treinado, certifique-se de verificar como ele foi treinado, em quais datasets, seus limites e seus enviesamentos. Todas estas informações devem ser indicadas em seu modelo de cartão.")},m(o,a){r(o,t,a)},d(o){o&&n(t)}}}function Ee(y){let t,o,a,b,u,c,d,s,i,J,F,W,le="O Model Hub torna simples a seleção do modelo apropriado, de modo que o uso em qualquer biblioteca pode ser feito em algumas linhas de código. Vamos dar uma olhada em como realmente usar um desses modelos, e como contribuir de volta à comunidade.",G,V,ne="Digamos que estamos à procura de um modelo baseado na língua francesa que possa realizar o enchimento de máscara.",X,C,oe='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/camembert.gif" alt="Selecting the Camembert model." width="80%"/>',S,v,re="Selecionamos o checkpoint <code>camembert-base</code> para experimentá-lo. O identificador <code>camembert-base</code> é tudo o que precisamos para começar a utilizá-lo! Como você já viu nos capítulos anteriores, podemos instanciá-lo utilizando a função <code>pipeline()</code>:",R,N,L,z,H,q,ie="Como você pode ver, carregar um modelo dentro de um pipeline é extremamente simples. A única coisa que você precisa estar atento é que o checkpoint escolhido é adequado para a tarefa para a qual ele será utilizado. Por exemplo, aqui estamos carregando o checkpoint <code>camembert-base</code> no pipeline <code>fill-mask</code>, o que é completamente bom. Mas se carregássemos este checkpoint no pipeline de <code>text-classification</code>, os resultados não fariam sentido porque a head da <code>camembert-base</code> não é adequado para esta tarefa! Recomendamos a utilização do seletor de tarefas na interface do Hub de abraço facial a fim de selecionar os checkpoints apropriados:",D,_,ce='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/tasks.png" alt="The task selector on the web interface." width="80%"/>',P,E,me="Você também pode instanciar o checkpoint usando diretamente a arquitetura modelo:",K,T,j,I,Z,O,A,ee;u=new Ze({props:{fw:y[0]}}),d=new We({props:{title:"Usando modelos pré-treinados",local:"usando-modelos-pré-treinados",headingTag:"h1"}});const pe=[ve,Ve],Q=[];function ue(e,l){return e[0]==="pt"?0:1}i=ue(y),J=Q[i]=pe[i](y),N=new Y({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}}),z=new Y({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=[ze,Ne],B=[];function be(e,l){return e[0]==="pt"?0:1}return T=be(y),j=B[T]=de[T](y),Z=new _e({props:{$$slots:{default:[qe]},$$scope:{ctx:y}}}),{c(){t=h("meta"),o=m(),a=h("p"),b=m(),k(u.$$.fragment),c=m(),k(d.$$.fragment),s=m(),J.c(),F=m(),W=h("p"),W.textContent=le,G=m(),V=h("p"),V.textContent=ne,X=m(),C=h("div"),C.innerHTML=oe,S=m(),v=h("p"),v.innerHTML=re,R=m(),k(N.$$.fragment),L=m(),k(z.$$.fragment),H=m(),q=h("p"),q.innerHTML=ie,D=m(),_=h("div"),_.innerHTML=ce,P=m(),E=h("p"),E.textContent=me,K=m(),j.c(),I=m(),k(Z.$$.fragment),O=m(),A=h("p"),this.h()},l(e){const l=xe("svelte-u9bgzb",document.head);t=g(l,"META",{name:!0,content:!0}),l.forEach(n),o=p(e),a=g(e,"P",{}),ye(a).forEach(n),b=p(e),U(u.$$.fragment,e),c=p(e),U(d.$$.fragment,e),s=p(e),J.l(e),F=p(e),W=g(e,"P",{"data-svelte-h":!0}),w(W)!=="svelte-jpqfo5"&&(W.textContent=le),G=p(e),V=g(e,"P",{"data-svelte-h":!0}),w(V)!=="svelte-bet0t8"&&(V.textContent=ne),X=p(e),C=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(C)!=="svelte-4k6hvy"&&(C.innerHTML=oe),S=p(e),v=g(e,"P",{"data-svelte-h":!0}),w(v)!=="svelte-12iju4a"&&(v.innerHTML=re),R=p(e),U(N.$$.fragment,e),L=p(e),U(z.$$.fragment,e),H=p(e),q=g(e,"P",{"data-svelte-h":!0}),w(q)!=="svelte-yr3ada"&&(q.innerHTML=ie),D=p(e),_=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(_)!=="svelte-1cl7xbt"&&(_.innerHTML=ce),P=p(e),E=g(e,"P",{"data-svelte-h":!0}),w(E)!=="svelte-qwwut5"&&(E.textContent=me),K=p(e),j.l(e),I=p(e),U(Z.$$.fragment,e),O=p(e),A=g(e,"P",{}),ye(A).forEach(n),this.h()},h(){se(t,"name","hf:doc:metadata"),se(t,"content",Qe),se(C,"class","flex justify-center"),se(_,"class","flex justify-center")},m(e,l){$e(document.head,t),r(e,o,l),r(e,a,l),r(e,b,l),x(u,e,l),r(e,c,l),x(d,e,l),r(e,s,l),Q[i].m(e,l),r(e,F,l),r(e,W,l),r(e,G,l),r(e,V,l),r(e,X,l),r(e,C,l),r(e,S,l),r(e,v,l),r(e,R,l),x(N,e,l),r(e,L,l),x(z,e,l),r(e,H,l),r(e,q,l),r(e,D,l),r(e,_,l),r(e,P,l),r(e,E,l),r(e,K,l),B[T].m(e,l),r(e,I,l),x(Z,e,l),r(e,O,l),r(e,A,l),ee=!0},p(e,[l]){const fe={};l&1&&(fe.fw=e[0]),u.$set(fe);let te=i;i=ue(e),i!==te&&(ge(),f(Q[te],1,1,()=>{Q[te]=null}),he(),J=Q[i],J||(J=Q[i]=pe[i](e),J.c()),M(J,1),J.m(F.parentNode,F));let ae=T;T=be(e),T!==ae&&(ge(),f(B[ae],1,1,()=>{B[ae]=null}),he(),j=B[T],j||(j=B[T]=de[T](e),j.c()),M(j,1),j.m(I.parentNode,I));const Me={};l&2&&(Me.$$scope={dirty:l,ctx:e}),Z.$set(Me)},i(e){ee||(M(u.$$.fragment,e),M(d.$$.fragment,e),M(J),M(N.$$.fragment,e),M(z.$$.fragment,e),M(j),M(Z.$$.fragment,e),ee=!0)},o(e){f(u.$$.fragment,e),f(d.$$.fragment,e),f(J),f(N.$$.fragment,e),f(z.$$.fragment,e),f(j),f(Z.$$.fragment,e),ee=!1},d(e){e&&(n(o),n(a),n(b),n(c),n(s),n(F),n(W),n(G),n(V),n(X),n(C),n(S),n(v),n(R),n(L),n(H),n(q),n(D),n(_),n(P),n(E),n(K),n(I),n(O),n(A)),n(t),$(u,e),$(d,e),Q[i].d(e),$(N,e),$(z,e),B[T].d(e),$(Z,e)}}}const Qe='{"title":"Usando modelos pré-treinados","local":"usando-modelos-pré-treinados","sections":[],"depth":1}';function Be(y,t,o){let a="pt";return je(()=>{const b=new URLSearchParams(window.location.search);o(0,a=b.get("fw")||"pt")}),[a]}class Re extends ke{constructor(t){super(),Ue(this,t,Be,Ee,Te,{})}}export{Re as component};
