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 e,c as n,j as A,u as I,x as V,k as H,y as L,a,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 r,b,d,j,p,J,o,w,i,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,g,B;return p=new O({props:{title:"偏见和局限性",local:"偏见和局限性",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(){r=f("meta"),b=l(),d=f("p"),j=l(),_(p.$$.fragment),J=l(),_(o.$$.fragment),w=l(),i=f("p"),i.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(),g=f("p"),this.h()},l(s){const t=K("svelte-u9bgzb",document.head);r=M(t,"META",{name:!0,content:!0}),t.forEach(e),b=n(s),d=M(s,"P",{}),A(d).forEach(e),j=n(s),I(p.$$.fragment,s),J=n(s),I(o.$$.fragment,s),w=n(s),i=M(s,"P",{"data-svelte-h":!0}),V(i)!=="svelte-banzoe"&&(i.textContent=G),x=n(s),c=M(s,"P",{"data-svelte-h":!0}),V(c)!=="svelte-1386ijw"&&(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-103zmam"&&(h.innerHTML=E),$=n(s),y=M(s,"P",{"data-svelte-h":!0}),V(y)!=="svelte-psgo7b"&&(y.textContent=S),U=n(s),g=M(s,"P",{}),A(g).forEach(e),this.h()},h(){H(r,"name","hf:doc:metadata"),H(r,"content",ts)},m(s,t){L(document.head,r),a(s,b,t),a(s,d,t),a(s,j,t),W(p,s,t),a(s,J,t),W(o,s,t),a(s,w,t),a(s,i,t),a(s,x,t),a(s,c,t),a(s,T,t),W(m,s,t),a(s,k,t),W(u,s,t),a(s,C,t),a(s,h,t),a(s,$,t),a(s,y,t),a(s,U,t),a(s,g,t),B=!0},p:P,i(s){B||(N(p.$$.fragment,s),N(o.$$.fragment,s),N(m.$$.fragment,s),N(u.$$.fragment,s),B=!0)},o(s){v(p.$$.fragment,s),v(o.$$.fragment,s),v(m.$$.fragment,s),v(u.$$.fragment,s),B=!1},d(s){s&&(e(b),e(d),e(j),e(J),e(w),e(i),e(x),e(c),e(T),e(k),e(C),e(h),e($),e(y),e(U),e(g)),e(r),z(p,s),z(o,s),z(m,s),z(u,s)}}}const ts='{"title":"偏见和局限性","local":"偏见和局限性","sections":[],"depth":1}';function es(Q){return X(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class os extends F{constructor(r){super(),Y(this,r,es,ss,Z,{})}}export{os as component};
