import{s as R,n as Z,o as X}from"../chunks/scheduler.37c15a92.js";import{S as F,i as L,g as h,s as n,r as z,A as Y,h as M,f as s,c as i,j as S,u as I,x as v,k as A,y as K,a,v as _,d as V,t as W,w as q}from"../chunks/index.2bf4358c.js";import{C as P}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as D}from"../chunks/CourseFloatingBanner.06521e8b.js";import{H as O}from"../chunks/Heading.8ada512a.js";function ee(N){let l,b,g,j,o,w,r,J,p,Q="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.",T,c,E="Per vederne una rappresentazione rapida, torniamo all’esempio della pipeline <code>fill-mask</code> con il modello BERT:",k,m,x,u,$,d,G='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>).',C,f,H="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.",U,y,B;return o=new O({props:{title:"Bias e limiti",local:"bias-e-limiti",headingTag:"h1"}}),r=new D({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 P({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 P({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}}),{c(){l=h("meta"),b=n(),g=h("p"),j=n(),z(o.$$.fragment),w=n(),z(r.$$.fragment),J=n(),p=h("p"),p.textContent=Q,T=n(),c=h("p"),c.innerHTML=E,k=n(),z(m.$$.fragment),x=n(),z(u.$$.fragment),$=n(),d=h("p"),d.innerHTML=G,C=n(),f=h("p"),f.textContent=H,U=n(),y=h("p"),this.h()},l(e){const t=Y("svelte-u9bgzb",document.head);l=M(t,"META",{name:!0,content:!0}),t.forEach(s),b=i(e),g=M(e,"P",{}),S(g).forEach(s),j=i(e),I(o.$$.fragment,e),w=i(e),I(r.$$.fragment,e),J=i(e),p=M(e,"P",{"data-svelte-h":!0}),v(p)!=="svelte-fwj8uu"&&(p.textContent=Q),T=i(e),c=M(e,"P",{"data-svelte-h":!0}),v(c)!=="svelte-algpv3"&&(c.innerHTML=E),k=i(e),I(m.$$.fragment,e),x=i(e),I(u.$$.fragment,e),$=i(e),d=M(e,"P",{"data-svelte-h":!0}),v(d)!=="svelte-16mavt8"&&(d.innerHTML=G),C=i(e),f=M(e,"P",{"data-svelte-h":!0}),v(f)!=="svelte-fr28fs"&&(f.textContent=H),U=i(e),y=M(e,"P",{}),S(y).forEach(s),this.h()},h(){A(l,"name","hf:doc:metadata"),A(l,"content",te)},m(e,t){K(document.head,l),a(e,b,t),a(e,g,t),a(e,j,t),_(o,e,t),a(e,w,t),_(r,e,t),a(e,J,t),a(e,p,t),a(e,T,t),a(e,c,t),a(e,k,t),_(m,e,t),a(e,x,t),_(u,e,t),a(e,$,t),a(e,d,t),a(e,C,t),a(e,f,t),a(e,U,t),a(e,y,t),B=!0},p:Z,i(e){B||(V(o.$$.fragment,e),V(r.$$.fragment,e),V(m.$$.fragment,e),V(u.$$.fragment,e),B=!0)},o(e){W(o.$$.fragment,e),W(r.$$.fragment,e),W(m.$$.fragment,e),W(u.$$.fragment,e),B=!1},d(e){e&&(s(b),s(g),s(j),s(w),s(J),s(p),s(T),s(c),s(k),s(x),s($),s(d),s(C),s(f),s(U),s(y)),s(l),q(o,e),q(r,e),q(m,e),q(u,e)}}}const te='{"title":"Bias e limiti","local":"bias-e-limiti","sections":[],"depth":1}';function se(N){return X(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class re extends F{constructor(l){super(),L(this,l,se,ee,R,{})}}export{re as component};
