import{S as Js,i as Us,s as Ks,e as f,k as r,w as b,t as i,l as Os,M as Qs,c as m,d as s,m as p,x as k,a as h,h as u,b as A,G as o,g as l,y as g,o as $,p as Ls,q as _,B as d,v as Vs,n as Ws}from"../../chunks/vendor-hf-doc-builder.js";import{I as Xs}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as w}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Gs}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as Ys}from"../../chunks/FrameworkSwitchCourse-hf-doc-builder.js";function Zs(v){let a,c;return a=new Gs({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter2/section6_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section6_tf.ipynb"}]}}),{c(){b(a.$$.fragment)},l(n){k(a.$$.fragment,n)},m(n,j){g(a,n,j),c=!0},i(n){c||(_(a.$$.fragment,n),c=!0)},o(n){$(a.$$.fragment,n),c=!1},d(n){d(a,n)}}}function et(v){let a,c;return a=new Gs({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter2/section6_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter2/section6_pt.ipynb"}]}}),{c(){b(a.$$.fragment)},l(n){k(a.$$.fragment,n)},m(n,j){g(a,n,j),c=!0},i(n){c||(_(a.$$.fragment,n),c=!0)},o(n){$(a.$$.fragment,n),c=!1},d(n){d(a,n)}}}function st(v){let a,c;return a=new w({props:{code:`
`,highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint)
sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

tokens = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
output = model(**tokens)`}}),{c(){b(a.$$.fragment)},l(n){k(a.$$.fragment,n)},m(n,j){g(a,n,j),c=!0},i(n){c||(_(a.$$.fragment,n),c=!0)},o(n){$(a.$$.fragment,n),c=!1},d(n){d(a,n)}}}function tt(v){let a,c;return a=new w({props:{code:`
`,highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

tokens = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
output = model(**tokens)`}}),{c(){b(a.$$.fragment)},l(n){k(a.$$.fragment,n)},m(n,j){g(a,n,j),c=!0},i(n){c||(_(a.$$.fragment,n),c=!0)},o(n){$(a.$$.fragment,n),c=!1},d(n){d(a,n)}}}function nt(v){let a,c,n,j,C,Ue,ge,y,E,V,X,Ke,de,Y,Qe,je,F,qe,S,Ve,ue,Xe,Ye,we,Z,Ze,ve,H,ye,ee,es,Ee,N,Ie,se,ss,ze,R,Pe,te,ts,Te,B,Se,q,ns,ce,ls,as,fe,os,rs,me,ps,is,xe,M,De,T,x,he,O,us,$e,cs,Ae,ne,fs,Ce,L,Fe,W,He,le,ms,Ne,G,Re,J,Be,P,hs,_e,$s,_s,be,bs,ks,Me,U,gs,Oe,ae,ds,Le,I,z,oe,We;n=new Ys({props:{fw:v[0]}});const js=[et,Zs],K=[];function qs(e,t){return e[0]==="pt"?0:1}y=qs(v),E=K[y]=js[y](v),F=new w({props:{code:`

`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

checkpoint = <span class="hljs-string">&quot;distilbert-base-uncased-finetuned-sst-2-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)

sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

model_inputs = tokenizer(sequence)`}}),H=new w({props:{code:"",highlighted:`sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

model_inputs = tokenizer(sequence)`}}),N=new w({props:{code:"",highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

model_inputs = tokenizer(sequences)`}}),R=new w({props:{code:`
`,highlighted:`<span class="hljs-comment"># Will pad the sequences up to the maximum sequence length</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;longest&quot;</span>)

<span class="hljs-comment"># Will pad the sequences up to the model max length</span>
<span class="hljs-comment"># (512 for BERT or DistilBERT)</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;max_length&quot;</span>)

<span class="hljs-comment"># Will pad the sequences up to the specified max length</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-string">&quot;max_length&quot;</span>, max_length=<span class="hljs-number">8</span>)`}}),B=new w({props:{code:`
`,highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

<span class="hljs-comment"># Will truncate the sequences that are longer than the model max length</span>
<span class="hljs-comment"># (512 for BERT or DistilBERT)</span>
model_inputs = tokenizer(sequences, truncation=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Will truncate the sequences that are longer than the specified max length</span>
model_inputs = tokenizer(sequences, max_length=<span class="hljs-number">8</span>, truncation=<span class="hljs-literal">True</span>)`}}),M=new w({props:{code:`

`,highlighted:`sequences = [<span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>, <span class="hljs-string">&quot;So have I!&quot;</span>]

<span class="hljs-comment"># Returns PyTorch tensors</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># Returns TensorFlow tensors</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

<span class="hljs-comment"># Returns NumPy arrays</span>
model_inputs = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)`}}),O=new Xs({}),L=new w({props:{code:`
`,highlighted:`sequence = <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>

model_inputs = tokenizer(sequence)
<span class="hljs-built_in">print</span>(model_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])

tokens = tokenizer.tokenize(sequence)
ids = tokenizer.convert_tokens_to_ids(tokens)
<span class="hljs-built_in">print</span>(ids)`}}),W=new w({props:{code:`[101, 1045, 1005, 2310, 2042, 3403, 2005, 1037, 17662, 12172, 2607, 2026, 2878, 2166, 1012, 102]
[1045, 1005, 2310, 2042, 3403, 2005, 1037, 17662, 12172, 2607, 2026, 2878, 2166, 1012]`,highlighted:`[<span class="hljs-number">101</span>, <span class="hljs-number">1045</span>, <span class="hljs-number">1005</span>, <span class="hljs-number">2310</span>, <span class="hljs-number">2042</span>, <span class="hljs-number">3403</span>, <span class="hljs-number">2005</span>, <span class="hljs-number">1037</span>, <span class="hljs-number">17662</span>, <span class="hljs-number">12172</span>, <span class="hljs-number">2607</span>, <span class="hljs-number">2026</span>, <span class="hljs-number">2878</span>, <span class="hljs-number">2166</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>]
[<span class="hljs-number">1045</span>, <span class="hljs-number">1005</span>, <span class="hljs-number">2310</span>, <span class="hljs-number">2042</span>, <span class="hljs-number">3403</span>, <span class="hljs-number">2005</span>, <span class="hljs-number">1037</span>, <span class="hljs-number">17662</span>, <span class="hljs-number">12172</span>, <span class="hljs-number">2607</span>, <span class="hljs-number">2026</span>, <span class="hljs-number">2878</span>, <span class="hljs-number">2166</span>, <span class="hljs-number">1012</span>]`}}),G=new w({props:{code:`print(tokenizer.decode(model_inputs["input_ids"]))
print(tokenizer.decode(ids))`,highlighted:`<span class="hljs-built_in">print</span>(tokenizer.decode(model_inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]))
<span class="hljs-built_in">print</span>(tokenizer.decode(ids))`}}),J=new w({props:{code:`"[CLS] i've been waiting for a huggingface course my whole life. [SEP]"
"i've been waiting for a huggingface course my whole life."`,highlighted:`<span class="hljs-string">&quot;[CLS] i&#x27;ve been waiting for a huggingface course my whole life. [SEP]&quot;</span>
<span class="hljs-string">&quot;i&#x27;ve been waiting for a huggingface course my whole life.&quot;</span>`}});const ws=[tt,st],Q=[];function vs(e,t){return e[0]==="pt"?0:1}return I=vs(v),z=Q[I]=ws[I](v),{c(){a=f("meta"),c=r(),b(n.$$.fragment),j=r(),C=f("h1"),Ue=i("\u628A\u5B83\u4EEC\u653E\u5728\u4E00\u8D77"),ge=r(),E.c(),V=r(),X=f("p"),Ke=i("\u5728\u6700\u540E\u51E0\u8282\u4E2D\uFF0C\u6211\u4EEC\u4E00\u76F4\u5728\u5C3D\u6700\u5927\u52AA\u529B\u624B\u5DE5\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002\u6211\u4EEC\u63A2\u8BA8\u4E86\u6807\u8BB0\u5316\u5668\u7684\u5DE5\u4F5C\u539F\u7406\uFF0C\u5E76\u7814\u7A76\u4E86\u6807\u8BB0\u5316\u3001\u5230\u8F93\u5165ID\u7684\u8F6C\u6362\u3001\u586B\u5145\u3001\u622A\u65AD\u548C\u6CE8\u610F\u63A9\u7801\u3002"),de=r(),Y=f("p"),Qe=i("\u7136\u800C\uFF0C\u6B63\u5982\u6211\u4EEC\u5728\u7B2C2\u8282\u4E2D\u6240\u770B\u5230\u7684\uFF0C\u{1F917} Transformers API\u53EF\u4EE5\u901A\u8FC7\u4E00\u4E2A\u9AD8\u7EA7\u51FD\u6570\u4E3A\u6211\u4EEC\u5904\u7406\u6240\u6709\u8FD9\u4E9B\uFF0C\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u6DF1\u5165\u8BA8\u8BBA\u3002\u5F53\u4F60\u76F4\u63A5\u5728\u53E5\u5B50\u4E0A\u8C03\u7528\u6807\u8BB0\u5668\u65F6\uFF0C\u4F60\u4F1A\u5F97\u5230\u51C6\u5907\u901A\u8FC7\u6A21\u578B\u4F20\u9012\u7684\u8F93\u5165"),je=r(),b(F.$$.fragment),qe=r(),S=f("p"),Ve=i("\u8FD9\u91CC\uFF0C"),ue=f("code"),Xe=i("model_inputs"),Ye=i(`
\u53D8\u91CF\u5305\u542B\u6A21\u578B\u826F\u597D\u8FD0\u884C\u6240\u9700\u7684\u4E00\u5207\u3002\u5BF9\u4E8EDistilBERT\uFF0C\u5B83\u5305\u62EC\u8F93\u5165 ID\u548C\u6CE8\u610F\u529B\u63A9\u7801(attention mask)\u3002\u5176\u4ED6\u63A5\u53D7\u989D\u5916\u8F93\u5165\u7684\u6A21\u578B\u4E5F\u4F1A\u6709\u6807\u8BB0\u5668\u5BF9\u8C61\u7684\u8F93\u51FA\u3002`),we=r(),Z=f("p"),Ze=i("\u6B63\u5982\u6211\u4EEC\u5C06\u5728\u4E0B\u9762\u7684\u4E00\u4E9B\u793A\u4F8B\u4E2D\u770B\u5230\u7684\uFF0C\u8FD9\u79CD\u65B9\u6CD5\u975E\u5E38\u5F3A\u5927\u3002\u9996\u5148\uFF0C\u5B83\u53EF\u4EE5\u6807\u8BB0\u5355\u4E2A\u5E8F\u5217\uFF1A"),ve=r(),b(H.$$.fragment),ye=r(),ee=f("p"),es=i("\u5B83\u8FD8\u4E00\u6B21\u5904\u7406\u591A\u4E2A\u5E8F\u5217\uFF0C\u5E76\u4E14API\u6CA1\u6709\u4EFB\u4F55\u53D8\u5316\uFF1A"),Ee=r(),b(N.$$.fragment),Ie=r(),se=f("p"),ss=i("\u5B83\u53EF\u4EE5\u6839\u636E\u51E0\u4E2A\u76EE\u6807\u8FDB\u884C\u586B\u5145\uFF1A"),ze=r(),b(R.$$.fragment),Pe=r(),te=f("p"),ts=i("\u5B83\u8FD8\u53EF\u4EE5\u622A\u65AD\u5E8F\u5217:"),Te=r(),b(B.$$.fragment),Se=r(),q=f("p"),ns=i("\u6807\u8BB0\u5668\u5BF9\u8C61\u53EF\u4EE5\u5904\u7406\u5230\u7279\u5B9A\u6846\u67B6\u5F20\u91CF\u7684\u8F6C\u6362\uFF0C\u7136\u540E\u53EF\u4EE5\u76F4\u63A5\u53D1\u9001\u5230\u6A21\u578B\u3002\u4F8B\u5982\uFF0C\u5728\u4E0B\u9762\u7684\u4EE3\u7801\u793A\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u63D0\u793A\u6807\u8BB0\u5668\u4ECE\u4E0D\u540C\u7684\u6846\u67B6\u8FD4\u56DE\u5F20\u91CF\u2014\u2014"),ce=f("code"),ls=i('"pt"'),as=i("\u8FD4\u56DEPy Torch\u5F20\u91CF\uFF0C"),fe=f("code"),os=i('"tf"'),rs=i("\u8FD4\u56DETensorFlow\u5F20\u91CF\uFF0C"),me=f("code"),ps=i('"np"'),is=i("\u8FD4\u56DENumPy\u6570\u7EC4\uFF1A"),xe=r(),b(M.$$.fragment),De=r(),T=f("h2"),x=f("a"),he=f("span"),b(O.$$.fragment),us=r(),$e=f("span"),cs=i("\u7279\u6B8A\u8BCD\u7B26(token)"),Ae=r(),ne=f("p"),fs=i("\u5982\u679C\u6211\u4EEC\u770B\u4E00\u4E0B\u6807\u8BB0\u5668\u8FD4\u56DE\u7684\u8F93\u5165 ID\uFF0C\u6211\u4EEC\u4F1A\u53D1\u73B0\u5B83\u4EEC\u4E0E\u4E4B\u524D\u7684\u7565\u6709\u4E0D\u540C\uFF1A"),Ce=r(),b(L.$$.fragment),Fe=r(),b(W.$$.fragment),He=r(),le=f("p"),ms=i("\u4E00\u4E2A\u5728\u5F00\u59CB\u65F6\u6DFB\u52A0\u4E86\u4E00\u4E2A\u6807\u8BB0(token) ID\uFF0C\u4E00\u4E2A\u5728\u7ED3\u675F\u65F6\u6DFB\u52A0\u4E86\u4E00\u4E2A\u6807\u8BB0(token) ID\u3002\u8BA9\u6211\u4EEC\u89E3\u7801\u4E0A\u9762\u7684\u4E24\u4E2AID\u5E8F\u5217\uFF0C\u770B\u770B\u8FD9\u662F\u600E\u4E48\u56DE\u4E8B\uFF1A"),Ne=r(),b(G.$$.fragment),Re=r(),b(J.$$.fragment),Be=r(),P=f("p"),hs=i("\u6807\u8BB0\u5668\u5728\u5F00\u5934\u6DFB\u52A0\u4E86\u7279\u6B8A\u5355\u8BCD"),_e=f("code"),$s=i("[CLS]"),_s=i("\uFF0C\u5728\u7ED3\u5C3E\u6DFB\u52A0\u4E86\u7279\u6B8A\u5355\u8BCD"),be=f("code"),bs=i("[SEP]"),ks=i("\u3002\u8FD9\u662F\u56E0\u4E3A\u6A21\u578B\u662F\u7528\u8FD9\u4E9B\u6570\u636E\u9884\u8BAD\u7EC3\u7684\uFF0C\u6240\u4EE5\u4E3A\u4E86\u5F97\u5230\u76F8\u540C\u7684\u63A8\u7406\u7ED3\u679C\uFF0C\u6211\u4EEC\u8FD8\u9700\u8981\u6DFB\u52A0\u5B83\u4EEC\u3002\u8BF7\u6CE8\u610F\uFF0C\u6709\u4E9B\u6A21\u578B\u4E0D\u6DFB\u52A0\u7279\u6B8A\u5355\u8BCD\uFF0C\u6216\u8005\u6DFB\u52A0\u4E0D\u540C\u7684\u5355\u8BCD\uFF1B\u6A21\u578B\u4E5F\u53EF\u80FD\u53EA\u5728\u5F00\u5934\u6216\u7ED3\u5C3E\u6DFB\u52A0\u8FD9\u4E9B\u7279\u6B8A\u5355\u8BCD\u3002\u5728\u4EFB\u4F55\u60C5\u51B5\u4E0B\uFF0C\u6807\u8BB0\u5668\u90FD\u77E5\u9053\u9700\u8981\u54EA\u4E9B\u8BCD\u7B26\uFF0C\u5E76\u5C06\u4E3A\u60A8\u5904\u7406\u8FD9\u4E9B\u8BCD\u7B26\u3002"),Me=r(),U=f("h2"),gs=i("\u7ED3\u675F\uFF1A\u4ECE\u6807\u8BB0\u5668\u5230\u6A21\u578B"),Oe=r(),ae=f("p"),ds=i("\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u770B\u5230\u4E86\u6807\u8BB0\u5668\u5BF9\u8C61\u5728\u5E94\u7528\u4E8E\u6587\u672C\u65F6\u4F7F\u7528\u7684\u6240\u6709\u5355\u72EC\u6B65\u9AA4\uFF0C\u8BA9\u6211\u4EEC\u6700\u540E\u4E00\u6B21\u770B\u770B\u5B83\u5982\u4F55\u5904\u7406\u591A\u4E2A\u5E8F\u5217\uFF08\u586B\u5145\uFF01\uFF09\uFF0C\u975E\u5E38\u957F\u7684\u5E8F\u5217\uFF08\u622A\u65AD\uFF01\uFF09\uFF0C\u4EE5\u53CA\u591A\u79CD\u7C7B\u578B\u7684\u5F20\u91CF\u53CA\u5176\u4E3B\u8981API\uFF1A"),Le=r(),z.c(),oe=Os(),this.h()},l(e){const t=Qs('[data-svelte="svelte-1phssyn"]',document.head);a=m(t,"META",{name:!0,content:!0}),t.forEach(s),c=p(e),k(n.$$.fragment,e),j=p(e),C=m(e,"H1",{id:!0});var ke=h(C);Ue=u(ke,"\u628A\u5B83\u4EEC\u653E\u5728\u4E00\u8D77"),ke.forEach(s),ge=p(e),E.l(e),V=p(e),X=m(e,"P",{});var re=h(X);Ke=u(re,"\u5728\u6700\u540E\u51E0\u8282\u4E2D\uFF0C\u6211\u4EEC\u4E00\u76F4\u5728\u5C3D\u6700\u5927\u52AA\u529B\u624B\u5DE5\u5B8C\u6210\u5927\u90E8\u5206\u5DE5\u4F5C\u3002\u6211\u4EEC\u63A2\u8BA8\u4E86\u6807\u8BB0\u5316\u5668\u7684\u5DE5\u4F5C\u539F\u7406\uFF0C\u5E76\u7814\u7A76\u4E86\u6807\u8BB0\u5316\u3001\u5230\u8F93\u5165ID\u7684\u8F6C\u6362\u3001\u586B\u5145\u3001\u622A\u65AD\u548C\u6CE8\u610F\u63A9\u7801\u3002"),re.forEach(s),de=p(e),Y=m(e,"P",{});var pe=h(Y);Qe=u(pe,"\u7136\u800C\uFF0C\u6B63\u5982\u6211\u4EEC\u5728\u7B2C2\u8282\u4E2D\u6240\u770B\u5230\u7684\uFF0C\u{1F917} Transformers API\u53EF\u4EE5\u901A\u8FC7\u4E00\u4E2A\u9AD8\u7EA7\u51FD\u6570\u4E3A\u6211\u4EEC\u5904\u7406\u6240\u6709\u8FD9\u4E9B\uFF0C\u6211\u4EEC\u5C06\u5728\u8FD9\u91CC\u6DF1\u5165\u8BA8\u8BBA\u3002\u5F53\u4F60\u76F4\u63A5\u5728\u53E5\u5B50\u4E0A\u8C03\u7528\u6807\u8BB0\u5668\u65F6\uFF0C\u4F60\u4F1A\u5F97\u5230\u51C6\u5907\u901A\u8FC7\u6A21\u578B\u4F20\u9012\u7684\u8F93\u5165"),pe.forEach(s),je=p(e),k(F.$$.fragment,e),qe=p(e),S=m(e,"P",{});var Ge=h(S);Ve=u(Ge,"\u8FD9\u91CC\uFF0C"),ue=m(Ge,"CODE",{});var ys=h(ue);Xe=u(ys,"model_inputs"),ys.forEach(s),Ye=u(Ge,`
\u53D8\u91CF\u5305\u542B\u6A21\u578B\u826F\u597D\u8FD0\u884C\u6240\u9700\u7684\u4E00\u5207\u3002\u5BF9\u4E8EDistilBERT\uFF0C\u5B83\u5305\u62EC\u8F93\u5165 ID\u548C\u6CE8\u610F\u529B\u63A9\u7801(attention mask)\u3002\u5176\u4ED6\u63A5\u53D7\u989D\u5916\u8F93\u5165\u7684\u6A21\u578B\u4E5F\u4F1A\u6709\u6807\u8BB0\u5668\u5BF9\u8C61\u7684\u8F93\u51FA\u3002`),Ge.forEach(s),we=p(e),Z=m(e,"P",{});var Es=h(Z);Ze=u(Es,"\u6B63\u5982\u6211\u4EEC\u5C06\u5728\u4E0B\u9762\u7684\u4E00\u4E9B\u793A\u4F8B\u4E2D\u770B\u5230\u7684\uFF0C\u8FD9\u79CD\u65B9\u6CD5\u975E\u5E38\u5F3A\u5927\u3002\u9996\u5148\uFF0C\u5B83\u53EF\u4EE5\u6807\u8BB0\u5355\u4E2A\u5E8F\u5217\uFF1A"),Es.forEach(s),ve=p(e),k(H.$$.fragment,e),ye=p(e),ee=m(e,"P",{});var Is=h(ee);es=u(Is,"\u5B83\u8FD8\u4E00\u6B21\u5904\u7406\u591A\u4E2A\u5E8F\u5217\uFF0C\u5E76\u4E14API\u6CA1\u6709\u4EFB\u4F55\u53D8\u5316\uFF1A"),Is.forEach(s),Ee=p(e),k(N.$$.fragment,e),Ie=p(e),se=m(e,"P",{});var zs=h(se);ss=u(zs,"\u5B83\u53EF\u4EE5\u6839\u636E\u51E0\u4E2A\u76EE\u6807\u8FDB\u884C\u586B\u5145\uFF1A"),zs.forEach(s),ze=p(e),k(R.$$.fragment,e),Pe=p(e),te=m(e,"P",{});var Ps=h(te);ts=u(Ps,"\u5B83\u8FD8\u53EF\u4EE5\u622A\u65AD\u5E8F\u5217:"),Ps.forEach(s),Te=p(e),k(B.$$.fragment,e),Se=p(e),q=m(e,"P",{});var D=h(q);ns=u(D,"\u6807\u8BB0\u5668\u5BF9\u8C61\u53EF\u4EE5\u5904\u7406\u5230\u7279\u5B9A\u6846\u67B6\u5F20\u91CF\u7684\u8F6C\u6362\uFF0C\u7136\u540E\u53EF\u4EE5\u76F4\u63A5\u53D1\u9001\u5230\u6A21\u578B\u3002\u4F8B\u5982\uFF0C\u5728\u4E0B\u9762\u7684\u4EE3\u7801\u793A\u4F8B\u4E2D\uFF0C\u6211\u4EEC\u63D0\u793A\u6807\u8BB0\u5668\u4ECE\u4E0D\u540C\u7684\u6846\u67B6\u8FD4\u56DE\u5F20\u91CF\u2014\u2014"),ce=m(D,"CODE",{});var Ts=h(ce);ls=u(Ts,'"pt"'),Ts.forEach(s),as=u(D,"\u8FD4\u56DEPy Torch\u5F20\u91CF\uFF0C"),fe=m(D,"CODE",{});var Ss=h(fe);os=u(Ss,'"tf"'),Ss.forEach(s),rs=u(D,"\u8FD4\u56DETensorFlow\u5F20\u91CF\uFF0C"),me=m(D,"CODE",{});var xs=h(me);ps=u(xs,'"np"'),xs.forEach(s),is=u(D,"\u8FD4\u56DENumPy\u6570\u7EC4\uFF1A"),D.forEach(s),xe=p(e),k(M.$$.fragment,e),De=p(e),T=m(e,"H2",{class:!0});var Je=h(T);x=m(Je,"A",{id:!0,class:!0,href:!0});var Ds=h(x);he=m(Ds,"SPAN",{});var As=h(he);k(O.$$.fragment,As),As.forEach(s),Ds.forEach(s),us=p(Je),$e=m(Je,"SPAN",{});var Cs=h($e);cs=u(Cs,"\u7279\u6B8A\u8BCD\u7B26(token)"),Cs.forEach(s),Je.forEach(s),Ae=p(e),ne=m(e,"P",{});var Fs=h(ne);fs=u(Fs,"\u5982\u679C\u6211\u4EEC\u770B\u4E00\u4E0B\u6807\u8BB0\u5668\u8FD4\u56DE\u7684\u8F93\u5165 ID\uFF0C\u6211\u4EEC\u4F1A\u53D1\u73B0\u5B83\u4EEC\u4E0E\u4E4B\u524D\u7684\u7565\u6709\u4E0D\u540C\uFF1A"),Fs.forEach(s),Ce=p(e),k(L.$$.fragment,e),Fe=p(e),k(W.$$.fragment,e),He=p(e),le=m(e,"P",{});var Hs=h(le);ms=u(Hs,"\u4E00\u4E2A\u5728\u5F00\u59CB\u65F6\u6DFB\u52A0\u4E86\u4E00\u4E2A\u6807\u8BB0(token) ID\uFF0C\u4E00\u4E2A\u5728\u7ED3\u675F\u65F6\u6DFB\u52A0\u4E86\u4E00\u4E2A\u6807\u8BB0(token) ID\u3002\u8BA9\u6211\u4EEC\u89E3\u7801\u4E0A\u9762\u7684\u4E24\u4E2AID\u5E8F\u5217\uFF0C\u770B\u770B\u8FD9\u662F\u600E\u4E48\u56DE\u4E8B\uFF1A"),Hs.forEach(s),Ne=p(e),k(G.$$.fragment,e),Re=p(e),k(J.$$.fragment,e),Be=p(e),P=m(e,"P",{});var ie=h(P);hs=u(ie,"\u6807\u8BB0\u5668\u5728\u5F00\u5934\u6DFB\u52A0\u4E86\u7279\u6B8A\u5355\u8BCD"),_e=m(ie,"CODE",{});var Ns=h(_e);$s=u(Ns,"[CLS]"),Ns.forEach(s),_s=u(ie,"\uFF0C\u5728\u7ED3\u5C3E\u6DFB\u52A0\u4E86\u7279\u6B8A\u5355\u8BCD"),be=m(ie,"CODE",{});var Rs=h(be);bs=u(Rs,"[SEP]"),Rs.forEach(s),ks=u(ie,"\u3002\u8FD9\u662F\u56E0\u4E3A\u6A21\u578B\u662F\u7528\u8FD9\u4E9B\u6570\u636E\u9884\u8BAD\u7EC3\u7684\uFF0C\u6240\u4EE5\u4E3A\u4E86\u5F97\u5230\u76F8\u540C\u7684\u63A8\u7406\u7ED3\u679C\uFF0C\u6211\u4EEC\u8FD8\u9700\u8981\u6DFB\u52A0\u5B83\u4EEC\u3002\u8BF7\u6CE8\u610F\uFF0C\u6709\u4E9B\u6A21\u578B\u4E0D\u6DFB\u52A0\u7279\u6B8A\u5355\u8BCD\uFF0C\u6216\u8005\u6DFB\u52A0\u4E0D\u540C\u7684\u5355\u8BCD\uFF1B\u6A21\u578B\u4E5F\u53EF\u80FD\u53EA\u5728\u5F00\u5934\u6216\u7ED3\u5C3E\u6DFB\u52A0\u8FD9\u4E9B\u7279\u6B8A\u5355\u8BCD\u3002\u5728\u4EFB\u4F55\u60C5\u51B5\u4E0B\uFF0C\u6807\u8BB0\u5668\u90FD\u77E5\u9053\u9700\u8981\u54EA\u4E9B\u8BCD\u7B26\uFF0C\u5E76\u5C06\u4E3A\u60A8\u5904\u7406\u8FD9\u4E9B\u8BCD\u7B26\u3002"),ie.forEach(s),Me=p(e),U=m(e,"H2",{id:!0});var Bs=h(U);gs=u(Bs,"\u7ED3\u675F\uFF1A\u4ECE\u6807\u8BB0\u5668\u5230\u6A21\u578B"),Bs.forEach(s),Oe=p(e),ae=m(e,"P",{});var Ms=h(ae);ds=u(Ms,"\u73B0\u5728\u6211\u4EEC\u5DF2\u7ECF\u770B\u5230\u4E86\u6807\u8BB0\u5668\u5BF9\u8C61\u5728\u5E94\u7528\u4E8E\u6587\u672C\u65F6\u4F7F\u7528\u7684\u6240\u6709\u5355\u72EC\u6B65\u9AA4\uFF0C\u8BA9\u6211\u4EEC\u6700\u540E\u4E00\u6B21\u770B\u770B\u5B83\u5982\u4F55\u5904\u7406\u591A\u4E2A\u5E8F\u5217\uFF08\u586B\u5145\uFF01\uFF09\uFF0C\u975E\u5E38\u957F\u7684\u5E8F\u5217\uFF08\u622A\u65AD\uFF01\uFF09\uFF0C\u4EE5\u53CA\u591A\u79CD\u7C7B\u578B\u7684\u5F20\u91CF\u53CA\u5176\u4E3B\u8981API\uFF1A"),Ms.forEach(s),Le=p(e),z.l(e),oe=Os(),this.h()},h(){A(a,"name","hf:doc:metadata"),A(a,"content",JSON.stringify(lt)),A(C,"id",""),A(x,"id","token"),A(x,"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"),A(x,"href","#token"),A(T,"class","relative group"),A(U,"id","")},m(e,t){o(document.head,a),l(e,c,t),g(n,e,t),l(e,j,t),l(e,C,t),o(C,Ue),l(e,ge,t),K[y].m(e,t),l(e,V,t),l(e,X,t),o(X,Ke),l(e,de,t),l(e,Y,t),o(Y,Qe),l(e,je,t),g(F,e,t),l(e,qe,t),l(e,S,t),o(S,Ve),o(S,ue),o(ue,Xe),o(S,Ye),l(e,we,t),l(e,Z,t),o(Z,Ze),l(e,ve,t),g(H,e,t),l(e,ye,t),l(e,ee,t),o(ee,es),l(e,Ee,t),g(N,e,t),l(e,Ie,t),l(e,se,t),o(se,ss),l(e,ze,t),g(R,e,t),l(e,Pe,t),l(e,te,t),o(te,ts),l(e,Te,t),g(B,e,t),l(e,Se,t),l(e,q,t),o(q,ns),o(q,ce),o(ce,ls),o(q,as),o(q,fe),o(fe,os),o(q,rs),o(q,me),o(me,ps),o(q,is),l(e,xe,t),g(M,e,t),l(e,De,t),l(e,T,t),o(T,x),o(x,he),g(O,he,null),o(T,us),o(T,$e),o($e,cs),l(e,Ae,t),l(e,ne,t),o(ne,fs),l(e,Ce,t),g(L,e,t),l(e,Fe,t),g(W,e,t),l(e,He,t),l(e,le,t),o(le,ms),l(e,Ne,t),g(G,e,t),l(e,Re,t),g(J,e,t),l(e,Be,t),l(e,P,t),o(P,hs),o(P,_e),o(_e,$s),o(P,_s),o(P,be),o(be,bs),o(P,ks),l(e,Me,t),l(e,U,t),o(U,gs),l(e,Oe,t),l(e,ae,t),o(ae,ds),l(e,Le,t),Q[I].m(e,t),l(e,oe,t),We=!0},p(e,[t]){const ke={};t&1&&(ke.fw=e[0]),n.$set(ke);let re=y;y=qs(e),y!==re&&(Ws(),$(K[re],1,1,()=>{K[re]=null}),Ls(),E=K[y],E||(E=K[y]=js[y](e),E.c()),_(E,1),E.m(V.parentNode,V));let pe=I;I=vs(e),I!==pe&&(Ws(),$(Q[pe],1,1,()=>{Q[pe]=null}),Ls(),z=Q[I],z||(z=Q[I]=ws[I](e),z.c()),_(z,1),z.m(oe.parentNode,oe))},i(e){We||(_(n.$$.fragment,e),_(E),_(F.$$.fragment,e),_(H.$$.fragment,e),_(N.$$.fragment,e),_(R.$$.fragment,e),_(B.$$.fragment,e),_(M.$$.fragment,e),_(O.$$.fragment,e),_(L.$$.fragment,e),_(W.$$.fragment,e),_(G.$$.fragment,e),_(J.$$.fragment,e),_(z),We=!0)},o(e){$(n.$$.fragment,e),$(E),$(F.$$.fragment,e),$(H.$$.fragment,e),$(N.$$.fragment,e),$(R.$$.fragment,e),$(B.$$.fragment,e),$(M.$$.fragment,e),$(O.$$.fragment,e),$(L.$$.fragment,e),$(W.$$.fragment,e),$(G.$$.fragment,e),$(J.$$.fragment,e),$(z),We=!1},d(e){s(a),e&&s(c),d(n,e),e&&s(j),e&&s(C),e&&s(ge),K[y].d(e),e&&s(V),e&&s(X),e&&s(de),e&&s(Y),e&&s(je),d(F,e),e&&s(qe),e&&s(S),e&&s(we),e&&s(Z),e&&s(ve),d(H,e),e&&s(ye),e&&s(ee),e&&s(Ee),d(N,e),e&&s(Ie),e&&s(se),e&&s(ze),d(R,e),e&&s(Pe),e&&s(te),e&&s(Te),d(B,e),e&&s(Se),e&&s(q),e&&s(xe),d(M,e),e&&s(De),e&&s(T),d(O),e&&s(Ae),e&&s(ne),e&&s(Ce),d(L,e),e&&s(Fe),d(W,e),e&&s(He),e&&s(le),e&&s(Ne),d(G,e),e&&s(Re),d(J,e),e&&s(Be),e&&s(P),e&&s(Me),e&&s(U),e&&s(Oe),e&&s(ae),e&&s(Le),Q[I].d(e),e&&s(oe)}}}const lt={local:"",sections:[{local:"token",title:"\u7279\u6B8A\u8BCD\u7B26(token)"},{local:"",title:"\u7ED3\u675F\uFF1A\u4ECE\u6807\u8BB0\u5668\u5230\u6A21\u578B"}],title:"\u628A\u5B83\u4EEC\u653E\u5728\u4E00\u8D77"};function at(v,a,c){let n="pt";return Vs(()=>{const j=new URLSearchParams(window.location.search);c(0,n=j.get("fw")||"pt")}),[n]}class ct extends Js{constructor(a){super();Us(this,a,at,nt,Ks,{})}}export{ct as default,lt as metadata};
