import{s as el,o as ll}from"../chunks/scheduler.37c15a92.js";import{S as sl,i as tl,g as J,s as p,r,A as nl,h as y,f as t,c as o,j as De,u as M,x as w,k as Pe,y as al,a as n,v as m,t as i,b as Ke,d as u,w as b,p as Le}from"../chunks/index.2bf4358c.js";import{C as j}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Oe}from"../chunks/CourseFloatingBanner.06521e8b.js";import{F as pl}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as Be}from"../chunks/Heading.8ada512a.js";function ol(d){let a,c;return a=new Oe({props:{chapter:2,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/chapter2/section6_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter2/section6_tf.ipynb"}]}}),{c(){r(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,T){m(a,s,T),c=!0},i(s){c||(u(a.$$.fragment,s),c=!0)},o(s){i(a.$$.fragment,s),c=!1},d(s){b(a,s)}}}function cl(d){let a,c;return a=new Oe({props:{chapter:2,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/chapter2/section6_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter2/section6_pt.ipynb"}]}}),{c(){r(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,T){m(a,s,T),c=!0},i(s){c||(u(a.$$.fragment,s),c=!0)},o(s){i(a.$$.fragment,s),c=!1},d(s){b(a,s)}}}function il(d){let a,c;return a=new j({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtc3N0LTItZW5nbGlzaCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBc2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEF0b2tlbnMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBb3V0cHV0JTIwJTNEJTIwbW9kZWwoKip0b2tlbnMp",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)`,wrap:!1}}),{c(){r(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,T){m(a,s,T),c=!0},i(s){c||(u(a.$$.fragment,s),c=!0)},o(s){i(a.$$.fragment,s),c=!1},d(s){b(a,s)}}}function ul(d){let a,c;return a=new j({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFzZXF1ZW5jZXMlMjAlM0QlMjAlNUIlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMkMlMjAlMjJTbyUyMGhhdmUlMjBJISUyMiU1RCUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFvdXRwdXQlMjAlM0QlMjBtb2RlbCgqKnRva2Vucyk=",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)`,wrap:!1}}),{c(){r(a.$$.fragment)},l(s){M(a.$$.fragment,s)},m(s,T){m(a,s,T),c=!0},i(s){c||(u(a.$$.fragment,s),c=!0)},o(s){i(a.$$.fragment,s),c=!1},d(s){b(a,s)}}}function rl(d){let a,c,s,T,Z,se,g,te,h,f,O,V,Ge="在最后几节中，我们一直在尽最大努力手工完成大部分工作。我们探讨了标记化器的工作原理，并研究了标记化、到输入ID的转换、填充、截断和注意掩码。",ne,k,Xe="然而，正如我们在第2节中所看到的，🤗 Transformers API可以通过一个高级函数为我们处理所有这些，我们将在这里深入讨论。当你直接在句子上调用标记器时，你会得到准备通过模型传递的输入",ae,W,pe,$,Ne=`这里，<code>model_inputs</code>
变量包含模型良好运行所需的一切。对于DistilBERT，它包括输入 ID和注意力掩码(attention mask)。其他接受额外输入的模型也会有标记器对象的输出。`,oe,B,_e="正如我们将在下面的一些示例中看到的，这种方法非常强大。首先，它可以标记单个序列：",ce,G,ie,X,xe="它还一次处理多个序列，并且API没有任何变化：",ue,N,re,_,Se="它可以根据几个目标进行填充：",Me,x,me,S,ze="它还可以截断序列:",be,z,Je,C,Ce="标记器对象可以处理到特定框架张量的转换，然后可以直接发送到模型。例如，在下面的代码示例中，我们提示标记器从不同的框架返回张量——<code>&quot;pt&quot;</code>返回Py Torch张量，<code>&quot;tf&quot;</code>返回TensorFlow张量，<code>&quot;np&quot;</code>返回NumPy数组：",ye,R,Te,E,we,q,Re="如果我们看一下标记器返回的输入 ID，我们会发现它们与之前的略有不同：",je,v,de,Y,he,Q,Ee="一个在开始时添加了一个标记(token) ID，一个在结束时添加了一个标记(token) ID。让我们解码上面的两个ID序列，看看这是怎么回事：",fe,H,Ie,F,Ue,A,qe="标记器在开头添加了特殊单词<code>[CLS]</code>，在结尾添加了特殊单词<code>[SEP]</code>。这是因为模型是用这些数据预训练的，所以为了得到相同的推理结果，我们还需要添加它们。请注意，有些模型不添加特殊单词，或者添加不同的单词；模型也可能只在开头或结尾添加这些特殊单词。在任何情况下，标记器都知道需要哪些词符，并将为您处理这些词符。",Ze,D,ge,P,ve="现在我们已经看到了标记器对象在应用于文本时使用的所有单独步骤，让我们最后一次看看它如何处理多个序列（填充！），非常长的序列（截断！），以及多种类型的张量及其主要API：",Ve,I,U,ee,le,ke;Z=new pl({props:{fw:d[0]}}),g=new Be({props:{title:"把它们放在一起",local:"把它们放在一起",headingTag:"h1"}});const Ye=[cl,ol],K=[];function Qe(e,l){return e[0]==="pt"?0:1}h=Qe(d),f=K[h]=Ye[h](d),W=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQSUwQXNlcXVlbmNlJTIwJTNEJTIwJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTBBJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlKQ==",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)`,wrap:!1}}),G=new j({props:{code:"c2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2Up",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)`,wrap:!1}}),N=new j({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzKQ==",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)`,wrap:!1}}),x=new j({props:{code:"JTIzJTIwV2lsbCUyMHBhZCUyMHRoZSUyMHNlcXVlbmNlcyUyMHVwJTIwdG8lMjB0aGUlMjBtYXhpbXVtJTIwc2VxdWVuY2UlMjBsZW5ndGglMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRCUyMmxvbmdlc3QlMjIpJTBBJTBBJTIzJTIwV2lsbCUyMHBhZCUyMHRoZSUyMHNlcXVlbmNlcyUyMHVwJTIwdG8lMjB0aGUlMjBtb2RlbCUyMG1heCUyMGxlbmd0aCUwQSUyMyUyMCg1MTIlMjBmb3IlMjBCRVJUJTIwb3IlMjBEaXN0aWxCRVJUKSUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEJTIybWF4X2xlbmd0aCUyMiklMEElMEElMjMlMjBXaWxsJTIwcGFkJTIwdGhlJTIwc2VxdWVuY2VzJTIwdXAlMjB0byUyMHRoZSUyMHNwZWNpZmllZCUyMG1heCUyMGxlbmd0aCUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEJTIybWF4X2xlbmd0aCUyMiUyQyUyMG1heF9sZW5ndGglM0Q4KQ==",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>)`,wrap:!1}}),z=new j({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEElMjMlMjBXaWxsJTIwdHJ1bmNhdGUlMjB0aGUlMjBzZXF1ZW5jZXMlMjB0aGF0JTIwYXJlJTIwbG9uZ2VyJTIwdGhhbiUyMHRoZSUyMG1vZGVsJTIwbWF4JTIwbGVuZ3RoJTBBJTIzJTIwKDUxMiUyMGZvciUyMEJFUlQlMjBvciUyMERpc3RpbEJFUlQpJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMHRydW5jYXRpb24lM0RUcnVlKSUwQSUwQSUyMyUyMFdpbGwlMjB0cnVuY2F0ZSUyMHRoZSUyMHNlcXVlbmNlcyUyMHRoYXQlMjBhcmUlMjBsb25nZXIlMjB0aGFuJTIwdGhlJTIwc3BlY2lmaWVkJTIwbWF4JTIwbGVuZ3RoJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMG1heF9sZW5ndGglM0Q4JTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUp",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>)`,wrap:!1}}),R=new j({props:{code:"c2VxdWVuY2VzJTIwJTNEJTIwJTVCJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTIwJTIyU28lMjBoYXZlJTIwSSElMjIlNUQlMEElMEElMjMlMjBSZXR1cm5zJTIwUHlUb3JjaCUyMHRlbnNvcnMlMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQSUyMyUyMFJldHVybnMlMjBUZW5zb3JGbG93JTIwdGVuc29ycyUwQW1vZGVsX2lucHV0cyUyMCUzRCUyMHRva2VuaXplcihzZXF1ZW5jZXMlMkMlMjBwYWRkaW5nJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIpJTBBJTBBJTIzJTIwUmV0dXJucyUyME51bVB5JTIwYXJyYXlzJTBBbW9kZWxfaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMHBhZGRpbmclM0RUcnVlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJucCUyMik=",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>)`,wrap:!1}}),E=new Be({props:{title:"特殊词符(token)",local:"特殊词符(token)",headingTag:"h2"}}),v=new j({props:{code:"c2VxdWVuY2UlMjAlM0QlMjAlMjJJJ3ZlJTIwYmVlbiUyMHdhaXRpbmclMjBmb3IlMjBhJTIwSHVnZ2luZ0ZhY2UlMjBjb3Vyc2UlMjBteSUyMHdob2xlJTIwbGlmZS4lMjIlMEElMEFtb2RlbF9pbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2UpJTBBcHJpbnQobW9kZWxfaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVEKSUwQSUwQXRva2VucyUyMCUzRCUyMHRva2VuaXplci50b2tlbml6ZShzZXF1ZW5jZSklMEFpZHMlMjAlM0QlMjB0b2tlbml6ZXIuY29udmVydF90b2tlbnNfdG9faWRzKHRva2VucyklMEFwcmludChpZHMp",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)`,wrap:!1}}),Y=new j({props:{code:"JTVCMTAxJTJDJTIwMTA0NSUyQyUyMDEwMDUlMkMlMjAyMzEwJTJDJTIwMjA0MiUyQyUyMDM0MDMlMkMlMjAyMDA1JTJDJTIwMTAzNyUyQyUyMDE3NjYyJTJDJTIwMTIxNzIlMkMlMjAyNjA3JTJDJTIwMjAyNiUyQyUyMDI4NzglMkMlMjAyMTY2JTJDJTIwMTAxMiUyQyUyMDEwMiU1RCUwQSU1QjEwNDUlMkMlMjAxMDA1JTJDJTIwMjMxMCUyQyUyMDIwNDIlMkMlMjAzNDAzJTJDJTIwMjAwNSUyQyUyMDEwMzclMkMlMjAxNzY2MiUyQyUyMDEyMTcyJTJDJTIwMjYwNyUyQyUyMDIwMjYlMkMlMjAyODc4JTJDJTIwMjE2NiUyQyUyMDEwMTIlNUQ=",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>]`,wrap:!1}}),H=new j({props:{code:"cHJpbnQodG9rZW5pemVyLmRlY29kZShtb2RlbF9pbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQpKSUwQXByaW50KHRva2VuaXplci5kZWNvZGUoaWRzKSk=",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))`,wrap:!1}}),F=new j({props:{code:"JTIyJTVCQ0xTJTVEJTIwaSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMGh1Z2dpbmdmYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIwJTVCU0VQJTVEJTIyJTBBJTIyaSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMGh1Z2dpbmdmYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIy",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>`,wrap:!1}}),D=new Be({props:{title:"结束：从标记器到模型",local:"结束：从标记器到模型",headingTag:"h2"}});const He=[ul,il],L=[];function Fe(e,l){return e[0]==="pt"?0:1}return I=Fe(d),U=L[I]=He[I](d),{c(){a=J("meta"),c=p(),s=J("p"),T=p(),r(Z.$$.fragment),se=p(),r(g.$$.fragment),te=p(),f.c(),O=p(),V=J("p"),V.textContent=Ge,ne=p(),k=J("p"),k.textContent=Xe,ae=p(),r(W.$$.fragment),pe=p(),$=J("p"),$.innerHTML=Ne,oe=p(),B=J("p"),B.textContent=_e,ce=p(),r(G.$$.fragment),ie=p(),X=J("p"),X.textContent=xe,ue=p(),r(N.$$.fragment),re=p(),_=J("p"),_.textContent=Se,Me=p(),r(x.$$.fragment),me=p(),S=J("p"),S.textContent=ze,be=p(),r(z.$$.fragment),Je=p(),C=J("p"),C.innerHTML=Ce,ye=p(),r(R.$$.fragment),Te=p(),r(E.$$.fragment),we=p(),q=J("p"),q.textContent=Re,je=p(),r(v.$$.fragment),de=p(),r(Y.$$.fragment),he=p(),Q=J("p"),Q.textContent=Ee,fe=p(),r(H.$$.fragment),Ie=p(),r(F.$$.fragment),Ue=p(),A=J("p"),A.innerHTML=qe,Ze=p(),r(D.$$.fragment),ge=p(),P=J("p"),P.textContent=ve,Ve=p(),U.c(),ee=p(),le=J("p"),this.h()},l(e){const l=nl("svelte-u9bgzb",document.head);a=y(l,"META",{name:!0,content:!0}),l.forEach(t),c=o(e),s=y(e,"P",{}),De(s).forEach(t),T=o(e),M(Z.$$.fragment,e),se=o(e),M(g.$$.fragment,e),te=o(e),f.l(e),O=o(e),V=y(e,"P",{"data-svelte-h":!0}),w(V)!=="svelte-9ckwb8"&&(V.textContent=Ge),ne=o(e),k=y(e,"P",{"data-svelte-h":!0}),w(k)!=="svelte-lmb6iw"&&(k.textContent=Xe),ae=o(e),M(W.$$.fragment,e),pe=o(e),$=y(e,"P",{"data-svelte-h":!0}),w($)!=="svelte-vr6ivv"&&($.innerHTML=Ne),oe=o(e),B=y(e,"P",{"data-svelte-h":!0}),w(B)!=="svelte-1ys6k4x"&&(B.textContent=_e),ce=o(e),M(G.$$.fragment,e),ie=o(e),X=y(e,"P",{"data-svelte-h":!0}),w(X)!=="svelte-81qtyc"&&(X.textContent=xe),ue=o(e),M(N.$$.fragment,e),re=o(e),_=y(e,"P",{"data-svelte-h":!0}),w(_)!=="svelte-1brznle"&&(_.textContent=Se),Me=o(e),M(x.$$.fragment,e),me=o(e),S=y(e,"P",{"data-svelte-h":!0}),w(S)!=="svelte-1kgpxe"&&(S.textContent=ze),be=o(e),M(z.$$.fragment,e),Je=o(e),C=y(e,"P",{"data-svelte-h":!0}),w(C)!=="svelte-k51qrg"&&(C.innerHTML=Ce),ye=o(e),M(R.$$.fragment,e),Te=o(e),M(E.$$.fragment,e),we=o(e),q=y(e,"P",{"data-svelte-h":!0}),w(q)!=="svelte-1kdyhh7"&&(q.textContent=Re),je=o(e),M(v.$$.fragment,e),de=o(e),M(Y.$$.fragment,e),he=o(e),Q=y(e,"P",{"data-svelte-h":!0}),w(Q)!=="svelte-10lmw3t"&&(Q.textContent=Ee),fe=o(e),M(H.$$.fragment,e),Ie=o(e),M(F.$$.fragment,e),Ue=o(e),A=y(e,"P",{"data-svelte-h":!0}),w(A)!=="svelte-1g1k4vg"&&(A.innerHTML=qe),Ze=o(e),M(D.$$.fragment,e),ge=o(e),P=y(e,"P",{"data-svelte-h":!0}),w(P)!=="svelte-su2qfp"&&(P.textContent=ve),Ve=o(e),U.l(e),ee=o(e),le=y(e,"P",{}),De(le).forEach(t),this.h()},h(){Pe(a,"name","hf:doc:metadata"),Pe(a,"content",Ml)},m(e,l){al(document.head,a),n(e,c,l),n(e,s,l),n(e,T,l),m(Z,e,l),n(e,se,l),m(g,e,l),n(e,te,l),K[h].m(e,l),n(e,O,l),n(e,V,l),n(e,ne,l),n(e,k,l),n(e,ae,l),m(W,e,l),n(e,pe,l),n(e,$,l),n(e,oe,l),n(e,B,l),n(e,ce,l),m(G,e,l),n(e,ie,l),n(e,X,l),n(e,ue,l),m(N,e,l),n(e,re,l),n(e,_,l),n(e,Me,l),m(x,e,l),n(e,me,l),n(e,S,l),n(e,be,l),m(z,e,l),n(e,Je,l),n(e,C,l),n(e,ye,l),m(R,e,l),n(e,Te,l),m(E,e,l),n(e,we,l),n(e,q,l),n(e,je,l),m(v,e,l),n(e,de,l),m(Y,e,l),n(e,he,l),n(e,Q,l),n(e,fe,l),m(H,e,l),n(e,Ie,l),m(F,e,l),n(e,Ue,l),n(e,A,l),n(e,Ze,l),m(D,e,l),n(e,ge,l),n(e,P,l),n(e,Ve,l),L[I].m(e,l),n(e,ee,l),n(e,le,l),ke=!0},p(e,[l]){const Ae={};l&1&&(Ae.fw=e[0]),Z.$set(Ae);let We=h;h=Qe(e),h!==We&&(Le(),i(K[We],1,1,()=>{K[We]=null}),Ke(),f=K[h],f||(f=K[h]=Ye[h](e),f.c()),u(f,1),f.m(O.parentNode,O));let $e=I;I=Fe(e),I!==$e&&(Le(),i(L[$e],1,1,()=>{L[$e]=null}),Ke(),U=L[I],U||(U=L[I]=He[I](e),U.c()),u(U,1),U.m(ee.parentNode,ee))},i(e){ke||(u(Z.$$.fragment,e),u(g.$$.fragment,e),u(f),u(W.$$.fragment,e),u(G.$$.fragment,e),u(N.$$.fragment,e),u(x.$$.fragment,e),u(z.$$.fragment,e),u(R.$$.fragment,e),u(E.$$.fragment,e),u(v.$$.fragment,e),u(Y.$$.fragment,e),u(H.$$.fragment,e),u(F.$$.fragment,e),u(D.$$.fragment,e),u(U),ke=!0)},o(e){i(Z.$$.fragment,e),i(g.$$.fragment,e),i(f),i(W.$$.fragment,e),i(G.$$.fragment,e),i(N.$$.fragment,e),i(x.$$.fragment,e),i(z.$$.fragment,e),i(R.$$.fragment,e),i(E.$$.fragment,e),i(v.$$.fragment,e),i(Y.$$.fragment,e),i(H.$$.fragment,e),i(F.$$.fragment,e),i(D.$$.fragment,e),i(U),ke=!1},d(e){e&&(t(c),t(s),t(T),t(se),t(te),t(O),t(V),t(ne),t(k),t(ae),t(pe),t($),t(oe),t(B),t(ce),t(ie),t(X),t(ue),t(re),t(_),t(Me),t(me),t(S),t(be),t(Je),t(C),t(ye),t(Te),t(we),t(q),t(je),t(de),t(he),t(Q),t(fe),t(Ie),t(Ue),t(A),t(Ze),t(ge),t(P),t(Ve),t(ee),t(le)),t(a),b(Z,e),b(g,e),K[h].d(e),b(W,e),b(G,e),b(N,e),b(x,e),b(z,e),b(R,e),b(E,e),b(v,e),b(Y,e),b(H,e),b(F,e),b(D,e),L[I].d(e)}}}const Ml='{"title":"把它们放在一起","local":"把它们放在一起","sections":[{"title":"特殊词符(token)","local":"特殊词符(token)","sections":[],"depth":2},{"title":"结束：从标记器到模型","local":"结束：从标记器到模型","sections":[],"depth":2}],"depth":1}';function ml(d,a,c){let s="pt";return ll(()=>{const T=new URLSearchParams(window.location.search);c(0,s=T.get("fw")||"pt")}),[s]}class dl extends sl{constructor(a){super(),tl(this,a,ml,rl,el,{})}}export{dl as component};
