import{s as nl,o as al}from"../chunks/scheduler.cc52f4b9.js";import{S as pl,i as ol,e as J,s as p,c,h as il,a as y,d as t,b as o,f as Oe,g as m,j as w,k as el,l as ul,m as n,n as M,o as u,u as ll,t as r,p as b,v as tl}from"../chunks/index.9480bb2b.js";import{C as rl,H as xe,E as cl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.52103c90.js";import{C as j}from"../chunks/CodeBlock.c5404643.js";import{C as sl}from"../chunks/CourseFloatingBanner.78fb31df.js";import{F as ml}from"../chunks/FrameworkSwitchCourse.42d12053.js";function Ml(d){let a,i;return a=new sl({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(){c(a.$$.fragment)},l(s){m(a.$$.fragment,s)},m(s,T){M(a,s,T),i=!0},i(s){i||(r(a.$$.fragment,s),i=!0)},o(s){u(a.$$.fragment,s),i=!1},d(s){b(a,s)}}}function bl(d){let a,i;return a=new sl({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(){c(a.$$.fragment)},l(s){m(a.$$.fragment,s)},m(s,T){M(a,s,T),i=!0},i(s){i||(r(a.$$.fragment,s),i=!0)},o(s){u(a.$$.fragment,s),i=!1},d(s){b(a,s)}}}function Jl(d){let a,i;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(){c(a.$$.fragment)},l(s){m(a.$$.fragment,s)},m(s,T){M(a,s,T),i=!0},i(s){i||(r(a.$$.fragment,s),i=!0)},o(s){u(a.$$.fragment,s),i=!1},d(s){b(a,s)}}}function yl(d){let a,i;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(){c(a.$$.fragment)},l(s){m(a.$$.fragment,s)},m(s,T){M(a,s,T),i=!0},i(s){i||(r(a.$$.fragment,s),i=!0)},o(s){u(a.$$.fragment,s),i=!1},d(s){b(a,s)}}}function Tl(d){let a,i,s,T,Z,ne,g,ae,$,pe,h,f,le,V,_e="在最後幾節中，我們一直在盡最大努力手工完成大部分工作。我們探討了標記化器的工作原理，並研究了標記化、到輸入ID的轉換、填充、截斷和注意掩碼。",oe,k,ze="然而，正如我們在第2節中所看到的，🤗 Transformers API可以通過一個高級函數為我們處理所有這些，我們將在這裡深入討論。當你直接在句子上調用標記器時，你會得到準備通過模型傳遞的輸入",ie,W,ue,B,Ce=`這裡，<code>model_inputs</code>
變量包含模型良好運行所需的一切。對於DistilBERT，它包括輸入 ID和注意力掩碼(attention mask)。其他接受額外輸入的模型也會有標記器對象的輸出。`,re,G,Se="正如我們將在下面的一些示例中看到的，這種方法非常強大。首先，它可以標記單個序列：",ce,X,me,N,Ee="它還一次處理多個序列，並且API沒有任何變化：",Me,x,be,_,Re="它可以根據幾個目標進行填充：",Je,z,ye,C,qe="它還可以截斷序列:",Te,S,we,E,ve="標記器對象可以處理到特定框架張量的轉換，然後可以直接發送到模型。例如，在下面的代碼示例中，我們提示標記器從不同的框架返回張量——<code>&quot;pt&quot;</code>返回Py Torch張量，<code>&quot;tf&quot;</code>返回TensorFlow張量，<code>&quot;np&quot;</code>返回NumPy數組：",je,R,de,q,he,v,Ye="如果我們看一下標記器返回的輸入 ID，我們會發現它們與之前的略有不同：",fe,Y,Ie,Q,Ue,H,Qe="一個在開始時添加了一個標記(token) ID，一個在結束時添加了一個標記(token) ID。讓我們解碼上面的兩個ID序列，看看這是怎麼回事：",Ze,F,ge,A,$e,D,He="標記器在開頭添加了特殊單詞<code>[CLS]</code>，在結尾添加了特殊單詞<code>[SEP]</code>。這是因為模型是用這些數據預訓練的，所以為了得到相同的推理結果，我們還需要添加它們。請注意，有些模型不添加特殊單詞，或者添加不同的單詞；模型也可能只在開頭或結尾添加這些特殊單詞。在任何情況下，標記器都知道需要哪些詞符，並將為您處理這些詞符。",Ve,P,ke,K,Fe="現在我們已經看到了標記器對象在應用於文本時使用的所有單獨步驟，讓我們最後一次看看它如何處理多個序列（填充！），非常長的序列（截斷！），以及多種類型的張量及其主要API：",We,I,U,te,L,Be,se,Ge;Z=new ml({props:{fw:d[0]}}),g=new rl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new xe({props:{title:"把它們放在一起",local:"把它們放在一起",headingTag:"h1"}});const Ae=[bl,Ml],O=[];function De(e,l){return e[0]==="pt"?0:1}h=De(d),f=O[h]=Ae[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}}),X=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}}),x=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}}),z=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}}),q=new xe({props:{title:"特殊詞符(token)",local:"特殊詞符token",headingTag:"h2"}}),Y=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}}),Q=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}}),F=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}}),A=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}}),P=new xe({props:{title:"結束：從標記器到模型",local:"結束從標記器到模型",headingTag:"h2"}});const Pe=[yl,Jl],ee=[];function Ke(e,l){return e[0]==="pt"?0:1}return I=Ke(d),U=ee[I]=Pe[I](d),L=new cl({props:{source:"https://github.com/huggingface/course/blob/main/chapters/zh-TW/chapter2/6.mdx"}}),{c(){a=J("meta"),i=p(),s=J("p"),T=p(),c(Z.$$.fragment),ne=p(),c(g.$$.fragment),ae=p(),c($.$$.fragment),pe=p(),f.c(),le=p(),V=J("p"),V.textContent=_e,oe=p(),k=J("p"),k.textContent=ze,ie=p(),c(W.$$.fragment),ue=p(),B=J("p"),B.innerHTML=Ce,re=p(),G=J("p"),G.textContent=Se,ce=p(),c(X.$$.fragment),me=p(),N=J("p"),N.textContent=Ee,Me=p(),c(x.$$.fragment),be=p(),_=J("p"),_.textContent=Re,Je=p(),c(z.$$.fragment),ye=p(),C=J("p"),C.textContent=qe,Te=p(),c(S.$$.fragment),we=p(),E=J("p"),E.innerHTML=ve,je=p(),c(R.$$.fragment),de=p(),c(q.$$.fragment),he=p(),v=J("p"),v.textContent=Ye,fe=p(),c(Y.$$.fragment),Ie=p(),c(Q.$$.fragment),Ue=p(),H=J("p"),H.textContent=Qe,Ze=p(),c(F.$$.fragment),ge=p(),c(A.$$.fragment),$e=p(),D=J("p"),D.innerHTML=He,Ve=p(),c(P.$$.fragment),ke=p(),K=J("p"),K.textContent=Fe,We=p(),U.c(),te=p(),c(L.$$.fragment),Be=p(),se=J("p"),this.h()},l(e){const l=il("svelte-u9bgzb",document.head);a=y(l,"META",{name:!0,content:!0}),l.forEach(t),i=o(e),s=y(e,"P",{}),Oe(s).forEach(t),T=o(e),m(Z.$$.fragment,e),ne=o(e),m(g.$$.fragment,e),ae=o(e),m($.$$.fragment,e),pe=o(e),f.l(e),le=o(e),V=y(e,"P",{"data-svelte-h":!0}),w(V)!=="svelte-ri56tg"&&(V.textContent=_e),oe=o(e),k=y(e,"P",{"data-svelte-h":!0}),w(k)!=="svelte-u0jeao"&&(k.textContent=ze),ie=o(e),m(W.$$.fragment,e),ue=o(e),B=y(e,"P",{"data-svelte-h":!0}),w(B)!=="svelte-5h1ym8"&&(B.innerHTML=Ce),re=o(e),G=y(e,"P",{"data-svelte-h":!0}),w(G)!=="svelte-1bzsmax"&&(G.textContent=Se),ce=o(e),m(X.$$.fragment,e),me=o(e),N=y(e,"P",{"data-svelte-h":!0}),w(N)!=="svelte-p5w8o5"&&(N.textContent=Ee),Me=o(e),m(x.$$.fragment,e),be=o(e),_=y(e,"P",{"data-svelte-h":!0}),w(_)!=="svelte-1fjb09c"&&(_.textContent=Re),Je=o(e),m(z.$$.fragment,e),ye=o(e),C=y(e,"P",{"data-svelte-h":!0}),w(C)!=="svelte-slyf0"&&(C.textContent=qe),Te=o(e),m(S.$$.fragment,e),we=o(e),E=y(e,"P",{"data-svelte-h":!0}),w(E)!=="svelte-15ecj1e"&&(E.innerHTML=ve),je=o(e),m(R.$$.fragment,e),de=o(e),m(q.$$.fragment,e),he=o(e),v=y(e,"P",{"data-svelte-h":!0}),w(v)!=="svelte-ziny2a"&&(v.textContent=Ye),fe=o(e),m(Y.$$.fragment,e),Ie=o(e),m(Q.$$.fragment,e),Ue=o(e),H=y(e,"P",{"data-svelte-h":!0}),w(H)!=="svelte-1c0bvep"&&(H.textContent=Qe),Ze=o(e),m(F.$$.fragment,e),ge=o(e),m(A.$$.fragment,e),$e=o(e),D=y(e,"P",{"data-svelte-h":!0}),w(D)!=="svelte-njyngw"&&(D.innerHTML=He),Ve=o(e),m(P.$$.fragment,e),ke=o(e),K=y(e,"P",{"data-svelte-h":!0}),w(K)!=="svelte-evt9m7"&&(K.textContent=Fe),We=o(e),U.l(e),te=o(e),m(L.$$.fragment,e),Be=o(e),se=y(e,"P",{}),Oe(se).forEach(t),this.h()},h(){el(a,"name","hf:doc:metadata"),el(a,"content",wl)},m(e,l){ul(document.head,a),n(e,i,l),n(e,s,l),n(e,T,l),M(Z,e,l),n(e,ne,l),M(g,e,l),n(e,ae,l),M($,e,l),n(e,pe,l),O[h].m(e,l),n(e,le,l),n(e,V,l),n(e,oe,l),n(e,k,l),n(e,ie,l),M(W,e,l),n(e,ue,l),n(e,B,l),n(e,re,l),n(e,G,l),n(e,ce,l),M(X,e,l),n(e,me,l),n(e,N,l),n(e,Me,l),M(x,e,l),n(e,be,l),n(e,_,l),n(e,Je,l),M(z,e,l),n(e,ye,l),n(e,C,l),n(e,Te,l),M(S,e,l),n(e,we,l),n(e,E,l),n(e,je,l),M(R,e,l),n(e,de,l),M(q,e,l),n(e,he,l),n(e,v,l),n(e,fe,l),M(Y,e,l),n(e,Ie,l),M(Q,e,l),n(e,Ue,l),n(e,H,l),n(e,Ze,l),M(F,e,l),n(e,ge,l),M(A,e,l),n(e,$e,l),n(e,D,l),n(e,Ve,l),M(P,e,l),n(e,ke,l),n(e,K,l),n(e,We,l),ee[I].m(e,l),n(e,te,l),M(L,e,l),n(e,Be,l),n(e,se,l),Ge=!0},p(e,[l]){const Le={};l&1&&(Le.fw=e[0]),Z.$set(Le);let Xe=h;h=De(e),h!==Xe&&(tl(),u(O[Xe],1,1,()=>{O[Xe]=null}),ll(),f=O[h],f||(f=O[h]=Ae[h](e),f.c()),r(f,1),f.m(le.parentNode,le));let Ne=I;I=Ke(e),I!==Ne&&(tl(),u(ee[Ne],1,1,()=>{ee[Ne]=null}),ll(),U=ee[I],U||(U=ee[I]=Pe[I](e),U.c()),r(U,1),U.m(te.parentNode,te))},i(e){Ge||(r(Z.$$.fragment,e),r(g.$$.fragment,e),r($.$$.fragment,e),r(f),r(W.$$.fragment,e),r(X.$$.fragment,e),r(x.$$.fragment,e),r(z.$$.fragment,e),r(S.$$.fragment,e),r(R.$$.fragment,e),r(q.$$.fragment,e),r(Y.$$.fragment,e),r(Q.$$.fragment,e),r(F.$$.fragment,e),r(A.$$.fragment,e),r(P.$$.fragment,e),r(U),r(L.$$.fragment,e),Ge=!0)},o(e){u(Z.$$.fragment,e),u(g.$$.fragment,e),u($.$$.fragment,e),u(f),u(W.$$.fragment,e),u(X.$$.fragment,e),u(x.$$.fragment,e),u(z.$$.fragment,e),u(S.$$.fragment,e),u(R.$$.fragment,e),u(q.$$.fragment,e),u(Y.$$.fragment,e),u(Q.$$.fragment,e),u(F.$$.fragment,e),u(A.$$.fragment,e),u(P.$$.fragment,e),u(U),u(L.$$.fragment,e),Ge=!1},d(e){e&&(t(i),t(s),t(T),t(ne),t(ae),t(pe),t(le),t(V),t(oe),t(k),t(ie),t(ue),t(B),t(re),t(G),t(ce),t(me),t(N),t(Me),t(be),t(_),t(Je),t(ye),t(C),t(Te),t(we),t(E),t(je),t(de),t(he),t(v),t(fe),t(Ie),t(Ue),t(H),t(Ze),t(ge),t($e),t(D),t(Ve),t(ke),t(K),t(We),t(te),t(Be),t(se)),t(a),b(Z,e),b(g,e),b($,e),O[h].d(e),b(W,e),b(X,e),b(x,e),b(z,e),b(S,e),b(R,e),b(q,e),b(Y,e),b(Q,e),b(F,e),b(A,e),b(P,e),ee[I].d(e),b(L,e)}}}const wl='{"title":"把它們放在一起","local":"把它們放在一起","sections":[{"title":"特殊詞符(token)","local":"特殊詞符token","sections":[],"depth":2},{"title":"結束：從標記器到模型","local":"結束從標記器到模型","sections":[],"depth":2}],"depth":1}';function jl(d,a,i){let s="pt";return al(()=>{const T=new URLSearchParams(window.location.search);i(0,s=T.get("fw")||"pt")}),[s]}class gl extends pl{constructor(a){super(),ol(this,a,jl,Tl,nl,{})}}export{gl as component};
