import{s as ke,o as Ue}from"../chunks/scheduler.37c15a92.js";import{S as xe,i as $e,g as h,s as c,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 Ce,a as o,v as j,t as f,b as Je,d as M,w as k,m as _e,n as Ze,p as Te}from"../chunks/index.2bf4358c.js";import{T as We}from"../chunks/Tip.363c041f.js";import{C as Y}from"../chunks/CodeBlock.4e987730.js";import{C as je}from"../chunks/CourseFloatingBanner.6add7356.js";import{F as Ve}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as ve,E as Ne}from"../chunks/getInferenceSnippets.8b9eb92a.js";function ze(y){let t,r;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(){J(t.$$.fragment)},l(a){T(t.$$.fragment,a)},m(a,b){j(t,a,b),r=!0},i(a){r||(M(t.$$.fragment,a),r=!0)},o(a){f(t.$$.fragment,a),r=!1},d(a){k(t,a)}}}function Ee(y){let t,r;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(){J(t.$$.fragment)},l(a){T(t.$$.fragment,a)},m(a,b){j(t,a,b),r=!0},i(a){r||(M(t.$$.fragment,a),r=!0)},o(a){f(t.$$.fragment,a),r=!1},d(a){k(t,a)}}}function qe(y){let t,r,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,p,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}}),p=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(){J(t.$$.fragment),r=c(),a=h("p"),a.innerHTML=b,u=c(),J(p.$$.fragment)},l(s){T(t.$$.fragment,s),r=m(s),a=g(s,"P",{"data-svelte-h":!0}),w(a)!=="svelte-3bgiy7"&&(a.innerHTML=b),u=m(s),T(p.$$.fragment,s)},m(s,i){j(t,s,i),o(s,r,i),o(s,a,i),o(s,u,i),j(p,s,i),d=!0},i(s){d||(M(t.$$.fragment,s),M(p.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(p.$$.fragment,s),d=!1},d(s){s&&(n(r),n(a),n(u)),k(t,s),k(p,s)}}}function Qe(y){let t,r,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,p,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}}),p=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(){J(t.$$.fragment),r=c(),a=h("p"),a.innerHTML=b,u=c(),J(p.$$.fragment)},l(s){T(t.$$.fragment,s),r=m(s),a=g(s,"P",{"data-svelte-h":!0}),w(a)!=="svelte-eqgo83"&&(a.innerHTML=b),u=m(s),T(p.$$.fragment,s)},m(s,i){j(t,s,i),o(s,r,i),o(s,a,i),o(s,u,i),j(p,s,i),d=!0},i(s){d||(M(t.$$.fragment,s),M(p.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(p.$$.fragment,s),d=!1},d(s){s&&(n(r),n(a),n(u)),k(t,s),k(p,s)}}}function Be(y){let t;return{c(){t=_e("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(r){t=Ze(r,"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(r,a){o(r,t,a)},d(r){r&&n(t)}}}function Fe(y){let t,r,a,b,u,p,d,s,i,U,G,W,oe="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.",X,V,re="Digamos que estamos à procura de um modelo baseado na língua francesa que possa realizar o enchimento de máscara.",S,C,ie='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/camembert.gif" alt="Selecting the Camembert model." width="80%"/>',R,v,ce="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>:",L,N,H,z,D,E,me="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:",P,_,pe='<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%"/>',K,q,ue="Você também pode instanciar o checkpoint usando diretamente a arquitetura modelo:",O,x,$,I,Z,ee,Q,se,A,te;u=new Ve({props:{fw:y[0]}}),d=new ve({props:{title:"Usando modelos pré-treinados",local:"usando-modelos-pré-treinados",headingTag:"h1"}});const de=[Ee,ze],B=[];function be(e,l){return e[0]==="pt"?0:1}i=be(y),U=B[i]=de[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 fe=[Qe,qe],F=[];function Me(e,l){return e[0]==="pt"?0:1}return x=Me(y),$=F[x]=fe[x](y),Z=new We({props:{$$slots:{default:[Be]},$$scope:{ctx:y}}}),Q=new Ne({props:{source:"https://github.com/huggingface/course/blob/main/chapters/pt/chapter4/2.mdx"}}),{c(){t=h("meta"),r=c(),a=h("p"),b=c(),J(u.$$.fragment),p=c(),J(d.$$.fragment),s=c(),U.c(),G=c(),W=h("p"),W.textContent=oe,X=c(),V=h("p"),V.textContent=re,S=c(),C=h("div"),C.innerHTML=ie,R=c(),v=h("p"),v.innerHTML=ce,L=c(),J(N.$$.fragment),H=c(),J(z.$$.fragment),D=c(),E=h("p"),E.innerHTML=me,P=c(),_=h("div"),_.innerHTML=pe,K=c(),q=h("p"),q.textContent=ue,O=c(),$.c(),I=c(),J(Z.$$.fragment),ee=c(),J(Q.$$.fragment),se=c(),A=h("p"),this.h()},l(e){const l=we("svelte-u9bgzb",document.head);t=g(l,"META",{name:!0,content:!0}),l.forEach(n),r=m(e),a=g(e,"P",{}),ge(a).forEach(n),b=m(e),T(u.$$.fragment,e),p=m(e),T(d.$$.fragment,e),s=m(e),U.l(e),G=m(e),W=g(e,"P",{"data-svelte-h":!0}),w(W)!=="svelte-jpqfo5"&&(W.textContent=oe),X=m(e),V=g(e,"P",{"data-svelte-h":!0}),w(V)!=="svelte-bet0t8"&&(V.textContent=re),S=m(e),C=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(C)!=="svelte-4k6hvy"&&(C.innerHTML=ie),R=m(e),v=g(e,"P",{"data-svelte-h":!0}),w(v)!=="svelte-12iju4a"&&(v.innerHTML=ce),L=m(e),T(N.$$.fragment,e),H=m(e),T(z.$$.fragment,e),D=m(e),E=g(e,"P",{"data-svelte-h":!0}),w(E)!=="svelte-yr3ada"&&(E.innerHTML=me),P=m(e),_=g(e,"DIV",{class:!0,"data-svelte-h":!0}),w(_)!=="svelte-1cl7xbt"&&(_.innerHTML=pe),K=m(e),q=g(e,"P",{"data-svelte-h":!0}),w(q)!=="svelte-qwwut5"&&(q.textContent=ue),O=m(e),$.l(e),I=m(e),T(Z.$$.fragment,e),ee=m(e),T(Q.$$.fragment,e),se=m(e),A=g(e,"P",{}),ge(A).forEach(n),this.h()},h(){ae(t,"name","hf:doc:metadata"),ae(t,"content",Ge),ae(C,"class","flex justify-center"),ae(_,"class","flex justify-center")},m(e,l){Ce(document.head,t),o(e,r,l),o(e,a,l),o(e,b,l),j(u,e,l),o(e,p,l),j(d,e,l),o(e,s,l),B[i].m(e,l),o(e,G,l),o(e,W,l),o(e,X,l),o(e,V,l),o(e,S,l),o(e,C,l),o(e,R,l),o(e,v,l),o(e,L,l),j(N,e,l),o(e,H,l),j(z,e,l),o(e,D,l),o(e,E,l),o(e,P,l),o(e,_,l),o(e,K,l),o(e,q,l),o(e,O,l),F[x].m(e,l),o(e,I,l),j(Z,e,l),o(e,ee,l),j(Q,e,l),o(e,se,l),o(e,A,l),te=!0},p(e,[l]){const ye={};l&1&&(ye.fw=e[0]),u.$set(ye);let le=i;i=be(e),i!==le&&(Te(),f(B[le],1,1,()=>{B[le]=null}),Je(),U=B[i],U||(U=B[i]=de[i](e),U.c()),M(U,1),U.m(G.parentNode,G));let ne=x;x=Me(e),x!==ne&&(Te(),f(F[ne],1,1,()=>{F[ne]=null}),Je(),$=F[x],$||($=F[x]=fe[x](e),$.c()),M($,1),$.m(I.parentNode,I));const he={};l&2&&(he.$$scope={dirty:l,ctx:e}),Z.$set(he)},i(e){te||(M(u.$$.fragment,e),M(d.$$.fragment,e),M(U),M(N.$$.fragment,e),M(z.$$.fragment,e),M($),M(Z.$$.fragment,e),M(Q.$$.fragment,e),te=!0)},o(e){f(u.$$.fragment,e),f(d.$$.fragment,e),f(U),f(N.$$.fragment,e),f(z.$$.fragment,e),f($),f(Z.$$.fragment,e),f(Q.$$.fragment,e),te=!1},d(e){e&&(n(r),n(a),n(b),n(p),n(s),n(G),n(W),n(X),n(V),n(S),n(C),n(R),n(v),n(L),n(H),n(D),n(E),n(P),n(_),n(K),n(q),n(O),n(I),n(ee),n(se),n(A)),n(t),k(u,e),k(d,e),B[i].d(e),k(N,e),k(z,e),F[x].d(e),k(Z,e),k(Q,e)}}}const Ge='{"title":"Usando modelos pré-treinados","local":"usando-modelos-pré-treinados","sections":[],"depth":1}';function Ie(y,t,r){let a="pt";return Ue(()=>{const b=new URLSearchParams(window.location.search);r(0,a=b.get("fw")||"pt")}),[a]}class De extends xe{constructor(t){super(),$e(this,t,Ie,Fe,ke,{})}}export{De as component};
