import{s as X,n as Y,o as K}from"../chunks/scheduler.cc52f4b9.js";import{S as D,i as O,e as g,s as n,c as w,h as ee,a as b,d as s,b as l,f as F,g as M,j as H,k as L,l as te,m as a,n as $,t as k,o as j,p as T}from"../chunks/index.5b747fde.js";import{C as se,H as ae,E as ne}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d38ac5a9.js";import{C as P}from"../chunks/CodeBlock.665bfc37.js";import{C as le}from"../chunks/CourseFloatingBanner.b33fcd79.js";function ie(S){let i,C,x,U,o,B,r,v,p,I,c,z="If your intent is to use a pretrained model or a fine-tuned version in production, please be aware that, while these models are powerful tools, they come with limitations. The biggest of these is that, to enable pretraining on large amounts of data, researchers often scrape all the content they can find, taking the best as well as the worst of what is available on the internet.",_,m,A="To give a quick illustration, let’s go back the example of a <code>fill-mask</code> pipeline with the BERT model:",V,h,W,u,N,f,R='When asked to fill in the missing word in these two sentences, the model gives only one gender-free answer (waiter/waitress). The others are work occupations usually associated with one specific gender — and yes, prostitute ended up in the top 5 possibilities the model associates with “woman” and “work.” This happens even though BERT is one of the rare Transformer models not built by scraping data from all over the internet, but rather using apparently neutral data (it’s trained on the <a href="https://huggingface.co/datasets/wikipedia" rel="nofollow">English Wikipedia</a> and <a href="https://huggingface.co/datasets/bookcorpus" rel="nofollow">BookCorpus</a> datasets).',q,d,Z="When you use these tools, you therefore need to keep in the back of your mind that the original model you are using could very easily generate sexist, racist, or homophobic content. Fine-tuning the model on your data won’t make this intrinsic bias disappear.",E,y,G,J,Q;return o=new se({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),r=new ae({props:{title:"Bias and limitations",local:"bias-and-limitations",headingTag:"h1"}}),p=new le({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/en/chapter1/section8.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter1/section8.ipynb"}]}}),h=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}}),y=new ne({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter1/9.mdx"}}),{c(){i=g("meta"),C=n(),x=g("p"),U=n(),w(o.$$.fragment),B=n(),w(r.$$.fragment),v=n(),w(p.$$.fragment),I=n(),c=g("p"),c.textContent=z,_=n(),m=g("p"),m.innerHTML=A,V=n(),w(h.$$.fragment),W=n(),w(u.$$.fragment),N=n(),f=g("p"),f.innerHTML=R,q=n(),d=g("p"),d.textContent=Z,E=n(),w(y.$$.fragment),G=n(),J=g("p"),this.h()},l(e){const t=ee("svelte-u9bgzb",document.head);i=b(t,"META",{name:!0,content:!0}),t.forEach(s),C=l(e),x=b(e,"P",{}),F(x).forEach(s),U=l(e),M(o.$$.fragment,e),B=l(e),M(r.$$.fragment,e),v=l(e),M(p.$$.fragment,e),I=l(e),c=b(e,"P",{"data-svelte-h":!0}),H(c)!=="svelte-1q5fkuw"&&(c.textContent=z),_=l(e),m=b(e,"P",{"data-svelte-h":!0}),H(m)!=="svelte-lenr95"&&(m.innerHTML=A),V=l(e),M(h.$$.fragment,e),W=l(e),M(u.$$.fragment,e),N=l(e),f=b(e,"P",{"data-svelte-h":!0}),H(f)!=="svelte-heqc6c"&&(f.innerHTML=R),q=l(e),d=b(e,"P",{"data-svelte-h":!0}),H(d)!=="svelte-u698k"&&(d.textContent=Z),E=l(e),M(y.$$.fragment,e),G=l(e),J=b(e,"P",{}),F(J).forEach(s),this.h()},h(){L(i,"name","hf:doc:metadata"),L(i,"content",oe)},m(e,t){te(document.head,i),a(e,C,t),a(e,x,t),a(e,U,t),$(o,e,t),a(e,B,t),$(r,e,t),a(e,v,t),$(p,e,t),a(e,I,t),a(e,c,t),a(e,_,t),a(e,m,t),a(e,V,t),$(h,e,t),a(e,W,t),$(u,e,t),a(e,N,t),a(e,f,t),a(e,q,t),a(e,d,t),a(e,E,t),$(y,e,t),a(e,G,t),a(e,J,t),Q=!0},p:Y,i(e){Q||(k(o.$$.fragment,e),k(r.$$.fragment,e),k(p.$$.fragment,e),k(h.$$.fragment,e),k(u.$$.fragment,e),k(y.$$.fragment,e),Q=!0)},o(e){j(o.$$.fragment,e),j(r.$$.fragment,e),j(p.$$.fragment,e),j(h.$$.fragment,e),j(u.$$.fragment,e),j(y.$$.fragment,e),Q=!1},d(e){e&&(s(C),s(x),s(U),s(B),s(v),s(I),s(c),s(_),s(m),s(V),s(W),s(N),s(f),s(q),s(d),s(E),s(G),s(J)),s(i),T(o,e),T(r,e),T(p,e),T(h,e),T(u,e),T(y,e)}}}const oe='{"title":"Bias and limitations","local":"bias-and-limitations","sections":[],"depth":1}';function re(S){return K(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fe extends D{constructor(i){super(),O(this,i,re,ie,X,{})}}export{fe as component};
