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