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