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,_,ze="它可以根據幾個目標進行填充：",Me,x,me,z,Se="它還可以截斷序列:",be,S,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}}),S=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=ze,Me=p(),r(x.$$.fragment),me=p(),z=J("p"),z.textContent=Se,be=p(),r(S.$$.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-ri56tg"&&(V.textContent=Ge),ne=o(e),k=y(e,"P",{"data-svelte-h":!0}),w(k)!=="svelte-u0jeao"&&(k.textContent=Xe),ae=o(e),M(W.$$.fragment,e),pe=o(e),$=y(e,"P",{"data-svelte-h":!0}),w($)!=="svelte-5h1ym8"&&($.innerHTML=Ne),oe=o(e),B=y(e,"P",{"data-svelte-h":!0}),w(B)!=="svelte-1bzsmax"&&(B.textContent=_e),ce=o(e),M(G.$$.fragment,e),ie=o(e),X=y(e,"P",{"data-svelte-h":!0}),w(X)!=="svelte-p5w8o5"&&(X.textContent=xe),ue=o(e),M(N.$$.fragment,e),re=o(e),_=y(e,"P",{"data-svelte-h":!0}),w(_)!=="svelte-1fjb09c"&&(_.textContent=ze),Me=o(e),M(x.$$.fragment,e),me=o(e),z=y(e,"P",{"data-svelte-h":!0}),w(z)!=="svelte-slyf0"&&(z.textContent=Se),be=o(e),M(S.$$.fragment,e),Je=o(e),C=y(e,"P",{"data-svelte-h":!0}),w(C)!=="svelte-15ecj1e"&&(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-ziny2a"&&(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-1c0bvep"&&(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-njyngw"&&(A.innerHTML=qe),Ze=o(e),M(D.$$.fragment,e),ge=o(e),P=y(e,"P",{"data-svelte-h":!0}),w(P)!=="svelte-evt9m7"&&(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,z,l),n(e,be,l),m(S,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(S.$$.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(S.$$.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(z),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(S,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};
