import{s as Z,n as P,o as X}from"../chunks/scheduler.37c15a92.js";import{S as F,i as Y,g as f,s as l,r as _,A as K,h as M,f as a,c as n,j as A,u as I,x as V,k as H,y as L,a as e,v as W,d as N,t as v,w as z}from"../chunks/index.2bf4358c.js";import{C as R}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as D}from"../chunks/CourseFloatingBanner.06521e8b.js";import{H as O}from"../chunks/Heading.8ada512a.js";function ss(Q){let i,b,d,g,r,J,o,w,p,G="如果您打算在正式的項目中使用經過預訓練或經過微調的模型。請注意：雖然這些模型是很強大，但它們也有侷限性。其中最大的一個問題是，爲了對大量數據進行預訓練，研究人員通常會蒐集所有他們能找到的內容，中間可能夾帶一些意識形態或者價值觀的刻板印象。",x,c,q="爲了快速解釋清楚這個問題，讓我們回到一個使用 BERT 模型的 pipeline 的例子：",T,m,k,u,C,h,E='當要求模型填寫這兩句話中缺少的單詞時，模型給出的答案中，只有一個與性別無關（服務生/女服務生）。其他職業通常與某一特定性別相關，妓女最終進入了模型中與「女人」和「工作」相關的前五位。儘管 BERT 是使用經過篩選和清洗後，明顯中立的數據集上建立的的 Transformer 模型，而不是通過從互聯網上搜集數據（它是在<a href="https://huggingface.co/datasets/wikipedia" rel="nofollow">Wikipedia 英文</a>和<a href="https://huggingface.co/datasets/bookcorpus" rel="nofollow">BookCorpus</a>數據集）。',$,y,S="因此，當您使用這些工具時，您需要記住，使用的原始模型的時候，很容易生成性別歧視、種族主義或恐同內容。這種固有偏見不會隨着微調模型而使消失。",U,j,B;return r=new O({props:{title:"Bias and limitations",local:"bias-and-limitations",headingTag:"h1"}}),o=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/zh-CN/chapter1/section8.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter1/section8.ipynb"}]}}),m=new R({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 R({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(){i=f("meta"),b=l(),d=f("p"),g=l(),_(r.$$.fragment),J=l(),_(o.$$.fragment),w=l(),p=f("p"),p.textContent=G,x=l(),c=f("p"),c.textContent=q,T=l(),_(m.$$.fragment),k=l(),_(u.$$.fragment),C=l(),h=f("p"),h.innerHTML=E,$=l(),y=f("p"),y.textContent=S,U=l(),j=f("p"),this.h()},l(s){const t=K("svelte-u9bgzb",document.head);i=M(t,"META",{name:!0,content:!0}),t.forEach(a),b=n(s),d=M(s,"P",{}),A(d).forEach(a),g=n(s),I(r.$$.fragment,s),J=n(s),I(o.$$.fragment,s),w=n(s),p=M(s,"P",{"data-svelte-h":!0}),V(p)!=="svelte-1ugu0s8"&&(p.textContent=G),x=n(s),c=M(s,"P",{"data-svelte-h":!0}),V(c)!=="svelte-j0crcv"&&(c.textContent=q),T=n(s),I(m.$$.fragment,s),k=n(s),I(u.$$.fragment,s),C=n(s),h=M(s,"P",{"data-svelte-h":!0}),V(h)!=="svelte-1bw0tjr"&&(h.innerHTML=E),$=n(s),y=M(s,"P",{"data-svelte-h":!0}),V(y)!=="svelte-1m6j9za"&&(y.textContent=S),U=n(s),j=M(s,"P",{}),A(j).forEach(a),this.h()},h(){H(i,"name","hf:doc:metadata"),H(i,"content",ts)},m(s,t){L(document.head,i),e(s,b,t),e(s,d,t),e(s,g,t),W(r,s,t),e(s,J,t),W(o,s,t),e(s,w,t),e(s,p,t),e(s,x,t),e(s,c,t),e(s,T,t),W(m,s,t),e(s,k,t),W(u,s,t),e(s,C,t),e(s,h,t),e(s,$,t),e(s,y,t),e(s,U,t),e(s,j,t),B=!0},p:P,i(s){B||(N(r.$$.fragment,s),N(o.$$.fragment,s),N(m.$$.fragment,s),N(u.$$.fragment,s),B=!0)},o(s){v(r.$$.fragment,s),v(o.$$.fragment,s),v(m.$$.fragment,s),v(u.$$.fragment,s),B=!1},d(s){s&&(a(b),a(d),a(g),a(J),a(w),a(p),a(x),a(c),a(T),a(k),a(C),a(h),a($),a(y),a(U),a(j)),a(i),z(r,s),z(o,s),z(m,s),z(u,s)}}}const ts='{"title":"Bias and limitations","local":"bias-and-limitations","sections":[],"depth":1}';function as(Q){return X(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class os extends F{constructor(i){super(),Y(this,i,as,ss,Z,{})}}export{os as component};
