import{S as dn,i as kn,s as bn,e as i,k as g,w as I,t as e,M as vn,c as r,d as t,m as f,a as l,x as O,h as c,b as p,G as h,g as a,y as V,L as yn,q as W,o as z,B as F,v as wn}from"../../chunks/vendor-hf-doc-builder.js";import{I as xn}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as fn}from"../../chunks/CodeBlock-hf-doc-builder.js";import{C as _n}from"../../chunks/CourseFloatingBanner-hf-doc-builder.js";import"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function $n(rn){let m,S,u,d,E,b,H,T,J,C,v,B,$,U,P,k,Q,A,X,Y,N,y,M,w,K,o,Z,x,nn,tn,_,sn,hn,R,j,an,D;return b=new xn({}),v=new _n({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/vi/chapter1/section8.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/vi/chapter1/section8.ipynb"}]}}),y=new fn({props:{code:`from transformers import pipeline

unmasker = pipeline("fill-mask", model="bert-base-uncased")
result = unmasker("This man works as a [MASK].")
print([r["token_str"] for r in result])

result = unmasker("This woman works as a [MASK].")
print([r["token_str"] for r in result])`,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])`}}),w=new fn({props:{code:`['lawyer', 'carpenter', 'doctor', 'waiter', 'mechanic']
['nurse', 'waitress', 'teacher', 'maid', 'prostitute']`,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>]`}}),{c(){m=i("meta"),S=g(),u=i("h1"),d=i("a"),E=i("span"),I(b.$$.fragment),H=g(),T=i("span"),J=e("Thi\xEAn ki\u1EBFn v\xE0 h\u1EA1n ch\u1EBF"),C=g(),I(v.$$.fragment),B=g(),$=i("p"),U=e("N\u1EBFu m\u1EE5c \u0111\xEDch c\u1EE7a b\u1EA1n l\xE0 s\u1EED d\u1EE5ng m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc ho\u1EB7c m\u1ED9t phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c tinh ch\u1EC9nh trong qu\xE1 tr\xECnh s\u1EA3n xu\u1EA5t, xin l\u01B0u \xFD r\u1EB1ng m\u1EB7c d\xF9 nh\u1EEFng m\xF4 h\xECnh n\xE0y l\xE0 nh\u1EEFng c\xF4ng c\u1EE5 m\u1EA1nh m\u1EBD nh\u01B0ng ch\xFAng c\u0169ng c\xF3 nh\u1EEFng h\u1EA1n ch\u1EBF. \u0110i\u1EC3m l\u1EDBn nh\u1EA5t trong s\u1ED1 \u0111\xF3 l\xE0, \u0111\u1EC3 cho ph\xE9p hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t l\u01B0\u1EE3ng l\u1EDBn d\u1EEF li\u1EC7u, c\xE1c nh\xE0 nghi\xEAn c\u1EE9u th\u01B0\u1EDDng thu th\u1EADp t\u1EA5t c\u1EA3 n\u1ED9i dung h\u1ECD c\xF3 th\u1EC3 t\xECm th\u1EA5y, l\u1EA5y n\u1ED9i dung t\u1ED1t nh\u1EA5t c\u0169ng nh\u01B0 x\u1EA5u nh\u1EA5t c\u1EE7a nh\u1EEFng g\xEC c\xF3 s\u1EB5n tr\xEAn internet."),P=g(),k=i("p"),Q=e("\u0110\u1EC3 \u0111\u01B0a ra m\u1ED9t minh h\u1ECDa nhanh, h\xE3y quay l\u1EA1i v\xED d\u1EE5 v\u1EC1 pipeline "),A=i("code"),X=e("fill-mask"),Y=e(" v\u1EDBi m\xF4 h\xECnh BERT:"),N=g(),I(y.$$.fragment),M=g(),I(w.$$.fragment),K=g(),o=i("p"),Z=e("Khi \u0111\u01B0\u1EE3c y\xEAu c\u1EA7u \u0111i\u1EC1n t\u1EEB c\xF2n thi\u1EBFu trong hai c\xE2u n\xE0y, m\xF4 h\xECnh ch\u1EC9 \u0111\u01B0a ra m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ph\xE2n bi\u1EC7t gi\u1EDBi t\xEDnh (waiter/waitress hay b\u1ED3i b\xE0n nam/b\u1ED3i b\xE0n n\u1EEF). Nh\u1EEFng c\xF4ng vi\u1EC7c kh\xE1c th\u01B0\u1EDDng g\u1EAFn v\u1EDBi m\u1ED9t gi\u1EDBi t\xEDnh c\u1EE5 th\u1EC3 - v\xE0 v\xE2ng, prostitute (g\xE1i m\u1EA1i d\xE2m) \u0111\xE3 n\u1EB1m trong 5 kh\u1EA3 n\u0103ng h\xE0ng \u0111\u1EA7u m\xE0 ng\u01B0\u1EDDi m\u1EABu k\u1EBFt h\u1EE3p v\u1EDBi \u201Cwoman\u201D (ph\u1EE5 n\u1EEF) v\xE0 \u201Cwork\u201D(c\xF4ng vi\u1EC7c). \u0110i\u1EC1u n\xE0y x\u1EA3y ra m\u1EB7c d\xF9 BERT l\xE0 m\u1ED9t trong nh\u1EEFng m\xF4 h\xECnh Transformer hi\u1EBFm hoi kh\xF4ng \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng b\u1EB1ng c\xE1ch thu th\u1EADp d\u1EEF li\u1EC7u t\u1EEB kh\u1EAFp n\u01A1i tr\xEAn internet, m\xE0 s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\xF3 v\u1EBB trung l\u1EADp (n\xF3 \u0111\u01B0\u1EE3c \u0111\xE0o t\u1EA1o tr\xEAn "),x=i("a"),nn=e("Wikipedia ti\u1EBFng Anh"),tn=e(" v\xE0 b\u1ED9 d\u1EEF li\u1EC7u "),_=i("a"),sn=e("BookCorpus"),hn=e("."),R=g(),j=i("p"),an=e("Do \u0111\xF3, khi b\u1EA1n s\u1EED d\u1EE5ng nh\u1EEFng c\xF4ng c\u1EE5 n\xE0y, b\u1EA1n c\u1EA7n l\u01B0u \xFD r\u1EB1ng m\xF4 h\xECnh g\u1ED1c m\xE0 b\u1EA1n \u0111ang s\u1EED d\u1EE5ng r\u1EA5t d\u1EC5 t\u1EA1o ra n\u1ED9i dung ph\xE2n bi\u1EC7t gi\u1EDBi t\xEDnh, ph\xE2n bi\u1EC7t ch\u1EE7ng t\u1ED9c, ho\u1EB7c k\u1EF3 th\u1ECB \u0111\u1ED3ng t\xEDnh. Vi\u1EC7c tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n s\u1EBD kh\xF4ng l\xE0m bi\u1EBFn m\u1EA5t xu h\u01B0\u1EDBng n\u1ED9i t\u1EA1i n\xE0y."),this.h()},l(n){const s=vn('[data-svelte="svelte-1phssyn"]',document.head);m=r(s,"META",{name:!0,content:!0}),s.forEach(t),S=f(n),u=r(n,"H1",{class:!0});var L=l(u);d=r(L,"A",{id:!0,class:!0,href:!0});var en=l(d);E=r(en,"SPAN",{});var ln=l(E);O(b.$$.fragment,ln),ln.forEach(t),en.forEach(t),H=f(L),T=r(L,"SPAN",{});var cn=l(T);J=c(cn,"Thi\xEAn ki\u1EBFn v\xE0 h\u1EA1n ch\u1EBF"),cn.forEach(t),L.forEach(t),C=f(n),O(v.$$.fragment,n),B=f(n),$=r(n,"P",{});var on=l($);U=c(on,"N\u1EBFu m\u1EE5c \u0111\xEDch c\u1EE7a b\u1EA1n l\xE0 s\u1EED d\u1EE5ng m\u1ED9t m\xF4 h\xECnh \u0111\u01B0\u1EE3c hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc ho\u1EB7c m\u1ED9t phi\xEAn b\u1EA3n \u0111\u01B0\u1EE3c tinh ch\u1EC9nh trong qu\xE1 tr\xECnh s\u1EA3n xu\u1EA5t, xin l\u01B0u \xFD r\u1EB1ng m\u1EB7c d\xF9 nh\u1EEFng m\xF4 h\xECnh n\xE0y l\xE0 nh\u1EEFng c\xF4ng c\u1EE5 m\u1EA1nh m\u1EBD nh\u01B0ng ch\xFAng c\u0169ng c\xF3 nh\u1EEFng h\u1EA1n ch\u1EBF. \u0110i\u1EC3m l\u1EDBn nh\u1EA5t trong s\u1ED1 \u0111\xF3 l\xE0, \u0111\u1EC3 cho ph\xE9p hu\u1EA5n luy\u1EC7n tr\u01B0\u1EDBc tr\xEAn m\u1ED9t l\u01B0\u1EE3ng l\u1EDBn d\u1EEF li\u1EC7u, c\xE1c nh\xE0 nghi\xEAn c\u1EE9u th\u01B0\u1EDDng thu th\u1EADp t\u1EA5t c\u1EA3 n\u1ED9i dung h\u1ECD c\xF3 th\u1EC3 t\xECm th\u1EA5y, l\u1EA5y n\u1ED9i dung t\u1ED1t nh\u1EA5t c\u0169ng nh\u01B0 x\u1EA5u nh\u1EA5t c\u1EE7a nh\u1EEFng g\xEC c\xF3 s\u1EB5n tr\xEAn internet."),on.forEach(t),P=f(n),k=r(n,"P",{});var G=l(k);Q=c(G,"\u0110\u1EC3 \u0111\u01B0a ra m\u1ED9t minh h\u1ECDa nhanh, h\xE3y quay l\u1EA1i v\xED d\u1EE5 v\u1EC1 pipeline "),A=r(G,"CODE",{});var pn=l(A);X=c(pn,"fill-mask"),pn.forEach(t),Y=c(G," v\u1EDBi m\xF4 h\xECnh BERT:"),G.forEach(t),N=f(n),O(y.$$.fragment,n),M=f(n),O(w.$$.fragment,n),K=f(n),o=r(n,"P",{});var q=l(o);Z=c(q,"Khi \u0111\u01B0\u1EE3c y\xEAu c\u1EA7u \u0111i\u1EC1n t\u1EEB c\xF2n thi\u1EBFu trong hai c\xE2u n\xE0y, m\xF4 h\xECnh ch\u1EC9 \u0111\u01B0a ra m\u1ED9t c\xE2u tr\u1EA3 l\u1EDDi kh\xF4ng ph\xE2n bi\u1EC7t gi\u1EDBi t\xEDnh (waiter/waitress hay b\u1ED3i b\xE0n nam/b\u1ED3i b\xE0n n\u1EEF). Nh\u1EEFng c\xF4ng vi\u1EC7c kh\xE1c th\u01B0\u1EDDng g\u1EAFn v\u1EDBi m\u1ED9t gi\u1EDBi t\xEDnh c\u1EE5 th\u1EC3 - v\xE0 v\xE2ng, prostitute (g\xE1i m\u1EA1i d\xE2m) \u0111\xE3 n\u1EB1m trong 5 kh\u1EA3 n\u0103ng h\xE0ng \u0111\u1EA7u m\xE0 ng\u01B0\u1EDDi m\u1EABu k\u1EBFt h\u1EE3p v\u1EDBi \u201Cwoman\u201D (ph\u1EE5 n\u1EEF) v\xE0 \u201Cwork\u201D(c\xF4ng vi\u1EC7c). \u0110i\u1EC1u n\xE0y x\u1EA3y ra m\u1EB7c d\xF9 BERT l\xE0 m\u1ED9t trong nh\u1EEFng m\xF4 h\xECnh Transformer hi\u1EBFm hoi kh\xF4ng \u0111\u01B0\u1EE3c x\xE2y d\u1EF1ng b\u1EB1ng c\xE1ch thu th\u1EADp d\u1EEF li\u1EC7u t\u1EEB kh\u1EAFp n\u01A1i tr\xEAn internet, m\xE0 s\u1EED d\u1EE5ng d\u1EEF li\u1EC7u c\xF3 v\u1EBB trung l\u1EADp (n\xF3 \u0111\u01B0\u1EE3c \u0111\xE0o t\u1EA1o tr\xEAn "),x=r(q,"A",{href:!0,rel:!0});var mn=l(x);nn=c(mn,"Wikipedia ti\u1EBFng Anh"),mn.forEach(t),tn=c(q," v\xE0 b\u1ED9 d\u1EEF li\u1EC7u "),_=r(q,"A",{href:!0,rel:!0});var un=l(_);sn=c(un,"BookCorpus"),un.forEach(t),hn=c(q,"."),q.forEach(t),R=f(n),j=r(n,"P",{});var gn=l(j);an=c(gn,"Do \u0111\xF3, khi b\u1EA1n s\u1EED d\u1EE5ng nh\u1EEFng c\xF4ng c\u1EE5 n\xE0y, b\u1EA1n c\u1EA7n l\u01B0u \xFD r\u1EB1ng m\xF4 h\xECnh g\u1ED1c m\xE0 b\u1EA1n \u0111ang s\u1EED d\u1EE5ng r\u1EA5t d\u1EC5 t\u1EA1o ra n\u1ED9i dung ph\xE2n bi\u1EC7t gi\u1EDBi t\xEDnh, ph\xE2n bi\u1EC7t ch\u1EE7ng t\u1ED9c, ho\u1EB7c k\u1EF3 th\u1ECB \u0111\u1ED3ng t\xEDnh. Vi\u1EC7c tinh ch\u1EC9nh m\xF4 h\xECnh tr\xEAn d\u1EEF li\u1EC7u c\u1EE7a b\u1EA1n s\u1EBD kh\xF4ng l\xE0m bi\u1EBFn m\u1EA5t xu h\u01B0\u1EDBng n\u1ED9i t\u1EA1i n\xE0y."),gn.forEach(t),this.h()},h(){p(m,"name","hf:doc:metadata"),p(m,"content",JSON.stringify(jn)),p(d,"id","thin-kin-v-hn-ch"),p(d,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(d,"href","#thin-kin-v-hn-ch"),p(u,"class","relative group"),p(x,"href","https://huggingface.co/datasets/wikipedia"),p(x,"rel","nofollow"),p(_,"href","https://huggingface.co/datasets/bookcorpus"),p(_,"rel","nofollow")},m(n,s){h(document.head,m),a(n,S,s),a(n,u,s),h(u,d),h(d,E),V(b,E,null),h(u,H),h(u,T),h(T,J),a(n,C,s),V(v,n,s),a(n,B,s),a(n,$,s),h($,U),a(n,P,s),a(n,k,s),h(k,Q),h(k,A),h(A,X),h(k,Y),a(n,N,s),V(y,n,s),a(n,M,s),V(w,n,s),a(n,K,s),a(n,o,s),h(o,Z),h(o,x),h(x,nn),h(o,tn),h(o,_),h(_,sn),h(o,hn),a(n,R,s),a(n,j,s),h(j,an),D=!0},p:yn,i(n){D||(W(b.$$.fragment,n),W(v.$$.fragment,n),W(y.$$.fragment,n),W(w.$$.fragment,n),D=!0)},o(n){z(b.$$.fragment,n),z(v.$$.fragment,n),z(y.$$.fragment,n),z(w.$$.fragment,n),D=!1},d(n){t(m),n&&t(S),n&&t(u),F(b),n&&t(C),F(v,n),n&&t(B),n&&t($),n&&t(P),n&&t(k),n&&t(N),F(y,n),n&&t(M),F(w,n),n&&t(K),n&&t(o),n&&t(R),n&&t(j)}}}const jn={local:"thin-kin-v-hn-ch",title:"Thi\xEAn ki\u1EBFn v\xE0 h\u1EA1n ch\u1EBF"};function qn(rn){return wn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bn extends dn{constructor(m){super();kn(this,m,qn,$n,bn,{})}}export{Bn as default,jn as metadata};
