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 l,c as $,h as tt,a as b,d as e,b as n,f as P,g as d,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 lt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.009dc98d.js";import{C as F}from"../chunks/CodeBlock.184aadb6.js";import{C as nt}from"../chunks/CourseFloatingBanner.6488bde3.js";function pt(q){let p,k,C,U,r,B,i,_,o,I,c,H="如果你打算在正式的项目中使用经过预训练或经过微调的模型。请注意：虽然这些模型是很强大，但它们也有局限性。其中最大的一个问题是，为了对大量数据进行预训练，研究人员通常会搜集所有他们能找到的所有文字内容，中间可能夹带一些意识形态或者价值观的刻板印象。",V,m,A="为了快速解释清楚这个问题，让我们回到一个使用 BERT 模型的 pipeline 的例子：",N,u,W,f,v,h,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,T,Q;return r=new et({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),i=new at({props:{title:"偏见和局限性",local:"偏见和局限性",headingTag:"h1"}}),o=new nt({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}}),f=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 lt({props:{source:"https://github.com/huggingface/course/blob/main/chapters/zh-CN/chapter1/8.mdx"}}),{c(){p=g("meta"),k=l(),C=g("p"),U=l(),$(r.$$.fragment),B=l(),$(i.$$.fragment),_=l(),$(o.$$.fragment),I=l(),c=g("p"),c.textContent=H,V=l(),m=g("p"),m.textContent=A,N=l(),$(u.$$.fragment),W=l(),$(f.$$.fragment),v=l(),h=g("p"),h.innerHTML=R,z=l(),y=g("p"),y.textContent=Z,E=l(),$(M.$$.fragment),G=l(),T=g("p"),this.h()},l(t){const s=tt("svelte-u9bgzb",document.head);p=b(s,"META",{name:!0,content:!0}),s.forEach(e),k=n(t),C=b(t,"P",{}),P(C).forEach(e),U=n(t),d(r.$$.fragment,t),B=n(t),d(i.$$.fragment,t),_=n(t),d(o.$$.fragment,t),I=n(t),c=b(t,"P",{"data-svelte-h":!0}),S(c)!=="svelte-14d8mf7"&&(c.textContent=H),V=n(t),m=b(t,"P",{"data-svelte-h":!0}),S(m)!=="svelte-27d4wy"&&(m.textContent=A),N=n(t),d(u.$$.fragment,t),W=n(t),d(f.$$.fragment,t),v=n(t),h=b(t,"P",{"data-svelte-h":!0}),S(h)!=="svelte-1j5rfw5"&&(h.innerHTML=R),z=n(t),y=b(t,"P",{"data-svelte-h":!0}),S(y)!=="svelte-11rtbii"&&(y.textContent=Z),E=n(t),d(M.$$.fragment,t),G=n(t),T=b(t,"P",{}),P(T).forEach(e),this.h()},h(){X(p,"name","hf:doc:metadata"),X(p,"content",rt)},m(t,s){st(document.head,p),a(t,k,s),a(t,C,s),a(t,U,s),j(r,t,s),a(t,B,s),j(i,t,s),a(t,_,s),j(o,t,s),a(t,I,s),a(t,c,s),a(t,V,s),a(t,m,s),a(t,N,s),j(u,t,s),a(t,W,s),j(f,t,s),a(t,v,s),a(t,h,s),a(t,z,s),a(t,y,s),a(t,E,s),j(M,t,s),a(t,G,s),a(t,T,s),Q=!0},p:L,i(t){Q||(w(r.$$.fragment,t),w(i.$$.fragment,t),w(o.$$.fragment,t),w(u.$$.fragment,t),w(f.$$.fragment,t),w(M.$$.fragment,t),Q=!0)},o(t){x(r.$$.fragment,t),x(i.$$.fragment,t),x(o.$$.fragment,t),x(u.$$.fragment,t),x(f.$$.fragment,t),x(M.$$.fragment,t),Q=!1},d(t){t&&(e(k),e(C),e(U),e(B),e(_),e(I),e(c),e(V),e(m),e(N),e(W),e(v),e(h),e(z),e(y),e(E),e(G),e(T)),e(p),J(r,t),J(i,t),J(o,t),J(u,t),J(f,t),J(M,t)}}}const rt='{"title":"偏见和局限性","local":"偏见和局限性","sections":[],"depth":1}';function it(q){return K(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ht extends D{constructor(p){super(),O(this,p,it,pt,Y,{})}}export{ht as component};
