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