import{s as X,n as F,o as L}from"../chunks/scheduler.37c15a92.js";import{S as Y,i as K,g,s as n,r as w,A as D,h as M,f as s,c as i,j as P,u as j,x as E,k as R,y as O,a,v as J,d as $,t as T,w as k}from"../chunks/index.2bf4358c.js";import{C as Z}from"../chunks/CodeBlock.4e987730.js";import{C as ee}from"../chunks/CourseFloatingBanner.9ff4c771.js";import{H as te,E as se}from"../chunks/getInferenceSnippets.ebf8be91.js";function ae(Q){let l,x,y,C,o,U,r,B,p,G="Se intendi utilizzare un modello pre-addestrato o una versione affinata in produzione, sii consapevole che i modelli sono degli strumenti potenti, ma hanno dei limiti. Il più grande limite è che, per permettere un pre-addestramento su una quantità importante di dati, i ricercatori spesso includono tutti i contenuti ai quali riescono ad accedere, prendendo nel contempo il meglio e il peggio di ciò che Intenet offre.",z,c,H="Per vederne una rappresentazione rapida, torniamo all’esempio della pipeline <code>fill-mask</code> con il modello BERT:",I,m,v,u,_,d,S='Quando domandiamo al modello di trovare la parola mancante in queste due frasi, questo produce solo una risposta senza genere predeterminato (‘waiter/waitress’). Le altre parole si riferiscono a professioni che sono solitamente associate ad un genere specifico; inoltre, come potete vedere, ‘prostitute’ finisce tra le 5 associazioni più probabili che il modello predice per “woman” e “work”. Ciò succede nonostante BERT sia uno dei rari modelli Transformer che non sono costruiti recuperando dati di ogni sorta da internet, ma utilizzando dati apparentemente neutri (è addestrato sui dataset <a href="https://huggingface.co/datasets/wikipedia" rel="nofollow">English Wikipedia</a> e <a href="https://huggingface.co/datasets/bookcorpus" rel="nofollow">BookCorpus</a>).',V,f,A="Nell’utilizzare questi strumenti, è perciò necessario tenere a mente che il modello d’origine in corso di utilizzazione potrebbe facilmente generare contenuti sessisti, razzisti oppure omofobici. Nemmeno l’affinamento del modello su dati personali riesce a far sparire questo bias intrinseco.",W,h,q,b,N;return o=new te({props:{title:"Bias e limiti",local:"bias-e-limiti",headingTag:"h1"}}),r=new ee({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/it/chapter1/section8.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/it/chapter1/section8.ipynb"}]}}),m=new Z({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdW5tYXNrZXIlMjAlM0QlMjBwaXBlbGluZSglMjJmaWxsLW1hc2slMjIlMkMlMjBtb2RlbCUzRCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXJlc3VsdCUyMCUzRCUyMHVubWFza2VyKCUyMlRoaXMlMjBtYW4lMjB3b3JrcyUyMGFzJTIwYSUyMCU1Qk1BU0slNUQuJTIyKSUwQXByaW50KCU1QnIlNUIlMjJ0b2tlbl9zdHIlMjIlNUQlMjBmb3IlMjByJTIwaW4lMjByZXN1bHQlNUQpJTBBJTBBcmVzdWx0JTIwJTNEJTIwdW5tYXNrZXIoJTIyVGhpcyUyMHdvbWFuJTIwd29ya3MlMjBhcyUyMGElMjAlNUJNQVNLJTVELiUyMiklMEFwcmludCglNUJyJTVCJTIydG9rZW5fc3RyJTIyJTVEJTIwZm9yJTIwciUyMGluJTIwcmVzdWx0JTVEKQ==",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])`,wrap:!1}}),u=new Z({props:{code:"JTVCJ2xhd3llciclMkMlMjAnY2FycGVudGVyJyUyQyUyMCdkb2N0b3InJTJDJTIwJ3dhaXRlciclMkMlMjAnbWVjaGFuaWMnJTVEJTBBJTVCJ251cnNlJyUyQyUyMCd3YWl0cmVzcyclMkMlMjAndGVhY2hlciclMkMlMjAnbWFpZCclMkMlMjAncHJvc3RpdHV0ZSclNUQ=",highlighted:`[<span class="hljs-string">&#x27;lawyer&#x27;</span>, <span class="hljs-string">&#x27;carpenter&#x27;</span>, <span class="hljs-string">&#x27;doctor&#x27;</span>, <span class="hljs-string">&#x27;waiter&#x27;</span>, <span class="hljs-string">&#x27;mechanic&#x27;</span>]
[<span class="hljs-string">&#x27;nurse&#x27;</span>, <span class="hljs-string">&#x27;waitress&#x27;</span>, <span class="hljs-string">&#x27;teacher&#x27;</span>, <span class="hljs-string">&#x27;maid&#x27;</span>, <span class="hljs-string">&#x27;prostitute&#x27;</span>]`,wrap:!1}}),h=new se({props:{source:"https://github.com/huggingface/course/blob/main/chapters/it/chapter1/8.mdx"}}),{c(){l=g("meta"),x=n(),y=g("p"),C=n(),w(o.$$.fragment),U=n(),w(r.$$.fragment),B=n(),p=g("p"),p.textContent=G,z=n(),c=g("p"),c.innerHTML=H,I=n(),w(m.$$.fragment),v=n(),w(u.$$.fragment),_=n(),d=g("p"),d.innerHTML=S,V=n(),f=g("p"),f.textContent=A,W=n(),w(h.$$.fragment),q=n(),b=g("p"),this.h()},l(e){const t=D("svelte-u9bgzb",document.head);l=M(t,"META",{name:!0,content:!0}),t.forEach(s),x=i(e),y=M(e,"P",{}),P(y).forEach(s),C=i(e),j(o.$$.fragment,e),U=i(e),j(r.$$.fragment,e),B=i(e),p=M(e,"P",{"data-svelte-h":!0}),E(p)!=="svelte-fwj8uu"&&(p.textContent=G),z=i(e),c=M(e,"P",{"data-svelte-h":!0}),E(c)!=="svelte-algpv3"&&(c.innerHTML=H),I=i(e),j(m.$$.fragment,e),v=i(e),j(u.$$.fragment,e),_=i(e),d=M(e,"P",{"data-svelte-h":!0}),E(d)!=="svelte-16mavt8"&&(d.innerHTML=S),V=i(e),f=M(e,"P",{"data-svelte-h":!0}),E(f)!=="svelte-fr28fs"&&(f.textContent=A),W=i(e),j(h.$$.fragment,e),q=i(e),b=M(e,"P",{}),P(b).forEach(s),this.h()},h(){R(l,"name","hf:doc:metadata"),R(l,"content",ne)},m(e,t){O(document.head,l),a(e,x,t),a(e,y,t),a(e,C,t),J(o,e,t),a(e,U,t),J(r,e,t),a(e,B,t),a(e,p,t),a(e,z,t),a(e,c,t),a(e,I,t),J(m,e,t),a(e,v,t),J(u,e,t),a(e,_,t),a(e,d,t),a(e,V,t),a(e,f,t),a(e,W,t),J(h,e,t),a(e,q,t),a(e,b,t),N=!0},p:F,i(e){N||($(o.$$.fragment,e),$(r.$$.fragment,e),$(m.$$.fragment,e),$(u.$$.fragment,e),$(h.$$.fragment,e),N=!0)},o(e){T(o.$$.fragment,e),T(r.$$.fragment,e),T(m.$$.fragment,e),T(u.$$.fragment,e),T(h.$$.fragment,e),N=!1},d(e){e&&(s(x),s(y),s(C),s(U),s(B),s(p),s(z),s(c),s(I),s(v),s(_),s(d),s(V),s(f),s(W),s(q),s(b)),s(l),k(o,e),k(r,e),k(m,e),k(u,e),k(h,e)}}}const ne='{"title":"Bias e limiti","local":"bias-e-limiti","sections":[],"depth":1}';function ie(Q){return L(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class me extends Y{constructor(l){super(),K(this,l,ie,ae,X,{})}}export{me as component};
