import{s as G,n as P,o as X}from"../chunks/scheduler.37c15a92.js";import{S as Y,i as Z,g as y,s as o,r as I,A as L,h as f,f as t,c as n,j as H,u as B,x as _,k as A,y as K,a,v as Q,d as V,t as x,w as W}from"../chunks/index.2bf4358c.js";import{C as F}from"../chunks/CodeBlock.4e987730.js";import{C as O}from"../chunks/CourseFloatingBanner.6add7356.js";import{H as D,E as ee}from"../chunks/getInferenceSnippets.1837c472.js";function se(S){let l,b,g,U,r,j,i,q,p,N="Se sua intenção é usar um modelo pré-treinado ou uma versão ajustada em produção, esteja ciente de que, embora esses modelos sejam ferramentas poderosas, eles vêm com limitações. A maior delas é que, para possibilitar o pré-treinamento em grandes quantidades de dados, os pesquisadores muitas vezes raspam todo o conteúdo que encontram, tirando o melhor e o pior do que está disponível na internet.",w,m,R="Para dar uma ilustração rápida, vamos voltar ao exemplo de um pipeline <code>fill-mask</code> com o modelo BERT:",J,u,T,c,E='Quando solicitado a preencher a palavra que falta nessas duas frases, o modelo dá apenas uma resposta livre de gênero (garçom/garçonete). As outras são ocupações de trabalho geralmente associadas a um gênero específico - e sim, prostituta acabou entre as 5 principais possibilidades que o modelo associa a “mulher” e “trabalho”. Isso acontece mesmo que o BERT seja um dos raros modelos de Transformer não construídos por meio de coleta de dados de toda a Internet, mas usando dados aparentemente neutros (ele é treinado com datasets da <a href="https://huggingface.co/datasets/wikipedia" rel="nofollow">Wikipedia em inglês</a> e <a href="https://huggingface.co/datasets/bookcorpus" rel="nofollow">BookCorpus</a>).',k,d,z="Quando você usa essas ferramentas, você precisa ter em mente que o modelo original que você está usando pode facilmente gerar conteúdo sexista, racista ou homofóbico. O ajuste fino do modelo em seus dados não fará com que esse viés intrínseco desapareça.",$,h,v,M,C;return r=new D({props:{title:"Vieses e limitações",local:"vieses-e-limitações",headingTag:"h1"}}),i=new O({props:{chapter:1,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/chapter1/section8.ipynb](https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/pt/chapter1/section8.ipynb)"},{label:"Aws Studio",value:"[https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/pt/chapter1/section8.ipynb](https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/pt/chapter1/section8.ipynb)"}]}}),u=new F({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdW5tYXNrZXIlMjAlM0QlMjBwaXBlbGluZSglMjJmaWxsLW1hc2slMjIlMkMlMjBtb2RlbCUzRCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXJlc3VsdCUyMCUzRCUyMHVubWFza2VyKCUyMlRoaXMlMjBtYW4lMjB3b3JrcyUyMGFzJTIwYSUyMCU1Qk1BU0slNUQuJTIyKSUwQXByaW50KCU1QnIlNUIlMjJ0b2tlbl9zdHIlMjIlNUQlMjBmb3IlMjByJTIwaW4lMjByZXN1bHQlNUQpJTBBJTBBcmVzdWx0JTIwJTNEJTIwdW5tYXNrZXIoJTIyVGhpcyUyMHdvbWFuJTIwd29ya3MlMjBhcyUyMGElMjAlNUJNQVNLJTVELiUyMiklMEFwcmludCglNUJyJTVCJTIydG9rZW5fc3RyJTIyJTVEJTIwZm9yJTIwciUyMGluJTIwcmVzdWx0JTVEKSUwQSUwQSU1QiUyMmxhd3llciUyMiUyQyUyMCUyMmNhcnBlbnRlciUyMiUyQyUyMCUyMmRvY3RvciUyMiUyQyUyMCUyMndhaXRlciUyMiUyQyUyMCUyMm1lY2hhbmljJTIyJTVEJTBBJTVCJTIybnVyc2UlMjIlMkMlMjAlMjJ3YWl0cmVzcyUyMiUyQyUyMCUyMnRlYWNoZXIlMjIlMkMlMjAlMjJtYWlkJTIyJTJDJTIwJTIycHJvc3RpdHV0ZSUyMiU1RA==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

unmasker = pipeline(<span class="hljs-string">&quot;fill-mask&quot;</span>, model=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
result = unmasker(<span class="hljs-string">&quot;This man works as a [MASK].&quot;</span>)
<span class="hljs-built_in">print</span>([r[<span class="hljs-string">&quot;token_str&quot;</span>] <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> result])

result = unmasker(<span class="hljs-string">&quot;This woman works as a [MASK].&quot;</span>)
<span class="hljs-built_in">print</span>([r[<span class="hljs-string">&quot;token_str&quot;</span>] <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> result])

[<span class="hljs-string">&quot;lawyer&quot;</span>, <span class="hljs-string">&quot;carpenter&quot;</span>, <span class="hljs-string">&quot;doctor&quot;</span>, <span class="hljs-string">&quot;waiter&quot;</span>, <span class="hljs-string">&quot;mechanic&quot;</span>]
[<span class="hljs-string">&quot;nurse&quot;</span>, <span class="hljs-string">&quot;waitress&quot;</span>, <span class="hljs-string">&quot;teacher&quot;</span>, <span class="hljs-string">&quot;maid&quot;</span>, <span class="hljs-string">&quot;prostitute&quot;</span>]`,wrap:!1}}),h=new ee({props:{source:"https://github.com/huggingface/course/blob/main/chapters/pt/chapter1/8.mdx"}}),{c(){l=y("meta"),b=o(),g=y("p"),U=o(),I(r.$$.fragment),j=o(),I(i.$$.fragment),q=o(),p=y("p"),p.textContent=N,w=o(),m=y("p"),m.innerHTML=R,J=o(),I(u.$$.fragment),T=o(),c=y("p"),c.innerHTML=E,k=o(),d=y("p"),d.textContent=z,$=o(),I(h.$$.fragment),v=o(),M=y("p"),this.h()},l(e){const s=L("svelte-u9bgzb",document.head);l=f(s,"META",{name:!0,content:!0}),s.forEach(t),b=n(e),g=f(e,"P",{}),H(g).forEach(t),U=n(e),B(r.$$.fragment,e),j=n(e),B(i.$$.fragment,e),q=n(e),p=f(e,"P",{"data-svelte-h":!0}),_(p)!=="svelte-16y7c0b"&&(p.textContent=N),w=n(e),m=f(e,"P",{"data-svelte-h":!0}),_(m)!=="svelte-my30tl"&&(m.innerHTML=R),J=n(e),B(u.$$.fragment,e),T=n(e),c=f(e,"P",{"data-svelte-h":!0}),_(c)!=="svelte-15xahqt"&&(c.innerHTML=E),k=n(e),d=f(e,"P",{"data-svelte-h":!0}),_(d)!=="svelte-1m5nzel"&&(d.textContent=z),$=n(e),B(h.$$.fragment,e),v=n(e),M=f(e,"P",{}),H(M).forEach(t),this.h()},h(){A(l,"name","hf:doc:metadata"),A(l,"content",te)},m(e,s){K(document.head,l),a(e,b,s),a(e,g,s),a(e,U,s),Q(r,e,s),a(e,j,s),Q(i,e,s),a(e,q,s),a(e,p,s),a(e,w,s),a(e,m,s),a(e,J,s),Q(u,e,s),a(e,T,s),a(e,c,s),a(e,k,s),a(e,d,s),a(e,$,s),Q(h,e,s),a(e,v,s),a(e,M,s),C=!0},p:P,i(e){C||(V(r.$$.fragment,e),V(i.$$.fragment,e),V(u.$$.fragment,e),V(h.$$.fragment,e),C=!0)},o(e){x(r.$$.fragment,e),x(i.$$.fragment,e),x(u.$$.fragment,e),x(h.$$.fragment,e),C=!1},d(e){e&&(t(b),t(g),t(U),t(j),t(q),t(p),t(w),t(m),t(J),t(T),t(c),t(k),t(d),t($),t(v),t(M)),t(l),W(r,e),W(i,e),W(u,e),W(h,e)}}}const te='{"title":"Vieses e limitações","local":"vieses-e-limitações","sections":[],"depth":1}';function ae(S){return X(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pe extends Y{constructor(l){super(),Z(this,l,ae,se,G,{})}}export{pe as component};
