import{s as Ga,o as Da,n as Fl}from"../chunks/scheduler.37c15a92.js";import{S as Ya,i as La,g as u,s as p,r as c,A as Fa,h as w,f as l,c as r,j as Ha,u as j,x as g,k as Yl,y as qa,a,v as y,t as J,b as Wl,d as i,w as T,p as vl}from"../chunks/index.2bf4358c.js";import{T as Ll}from"../chunks/Tip.363c041f.js";import{Y as Vl}from"../chunks/Youtube.1e50a667.js";import{C as U}from"../chunks/CodeBlock.4e987730.js";import{C as Xa}from"../chunks/CourseFloatingBanner.9ff4c771.js";import{F as Pa}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as Tn,E as Oa}from"../chunks/index.b8688d36.js";function Ka(b){let t,m;return t=new Xa({props:{chapter:6,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/chapter6/section3_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter6/section3_tf.ipynb"}]}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function st(b){let t,m;return t=new Xa({props:{chapter:6,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/chapter6/section3_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter6/section3_pt.ipynb"}]}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function nt(b){let t,m="⚠️ 對單個句子進行分詞時，您不會總是看到相同分詞器的慢速和快速版本之間的速度差異。事實上，快速版本實際上可能更慢！只有同時對大量文本進行標記時，您才能清楚地看到差異。";return{c(){t=u("p"),t.textContent=m},l(e){t=w(e,"P",{"data-svelte-h":!0}),g(t)!=="svelte-uv1430"&&(t.textContent=m)},m(e,o){a(e,t,o)},p:Fl,d(e){e&&l(t)}}}function lt(b){let t,m="一個詞是什麼的概念很複雜。例如，“I’ll”（“I will”的縮寫）算一兩個詞嗎？它實際上取決於分詞器和它應用的預分詞操作。一些標記器只是在空格上拆分，因此他們會將其視為一個詞。其他人在空格頂部使用標點符號，因此將其視為兩個詞。",e,o,f="✏️ 試試看！從bert base cased和roberta base檢查點創建一個標記器，並用它們標記“81s”。你觀察到了什麼？ID這個詞是什麼？";return{c(){t=u("p"),t.textContent=m,e=p(),o=u("p"),o.textContent=f},l(h){t=w(h,"P",{"data-svelte-h":!0}),g(t)!=="svelte-1l2ofoc"&&(t.textContent=m),e=r(h),o=w(h,"P",{"data-svelte-h":!0}),g(o)!=="svelte-6g3i9b"&&(o.textContent=f)},m(h,k){a(h,t,k),a(h,e,k),a(h,o,k)},p:Fl,d(h){h&&(l(t),l(e),l(o))}}}function at(b){let t,m="✏️ 試試看！創建您自己的示例文本，看看您是否能理解哪些標記與單詞 ID 相關聯，以及如何提取單個單詞的字符跨度。對於獎勵積分，請嘗試使用兩個句子作為輸入，看看句子 ID 是否對您有意義。";return{c(){t=u("p"),t.textContent=m},l(e){t=w(e,"P",{"data-svelte-h":!0}),g(t)!=="svelte-cy8tjv"&&(t.textContent=m)},m(e,o){a(e,t,o)},p:Fl,d(e){e&&l(t)}}}function tt(b){let t,m;return t=new Vl({props:{id:"PrX4CjrVnNc"}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function et(b){let t,m;return t=new Vl({props:{id:"0E7ltQB7fM8"}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function pt(b){let t,m='首先，我們需要標記我們的輸入並將其傳遞給模型。這是完全按照<a href="/course/chapter2">Chapter 2</a>;我們使用 <strong>AutoXxx</strong> 類，然後在我們的示例中使用它們：',e,o,f,h,k="於我們正在使用 <strong>AutoModelForTokenClassification</strong> 在這裡，我們為輸入序列中的每個標記獲得一組 logits：",A,x,C,I,$;return o=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbF9jaGVja3BvaW50JTIwJTNEJTIwJTIyZGJtZHolMkZiZXJ0LWxhcmdlLWNhc2VkLWZpbmV0dW5lZC1jb25sbDAzLWVuZ2xpc2glMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9jaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JUb2tlbkNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChtb2RlbF9jaGVja3BvaW50KSUwQSUwQWV4YW1wbGUlMjAlM0QlMjAlMjJNeSUyMG5hbWUlMjBpcyUyMFN5bHZhaW4lMjBhbmQlMjBJJTIwd29yayUyMGF0JTIwSHVnZ2luZyUyMEZhY2UlMjBpbiUyMEJyb29rbHluLiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihleGFtcGxlJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForTokenClassification

model_checkpoint = <span class="hljs-string">&quot;dbmdz/bert-large-cased-finetuned-conll03-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = TFAutoModelForTokenClassification.from_pretrained(model_checkpoint)

example = <span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>
inputs = tokenizer(example, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
outputs = model(**inputs)`,wrap:!1}}),x=new U({props:{code:"cHJpbnQoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlKSUwQXByaW50KG91dHB1dHMubG9naXRzLnNoYXBlKQ==",highlighted:`<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape)
<span class="hljs-built_in">print</span>(outputs.logits.shape)`,wrap:!1}}),I=new U({props:{code:"KDElMkMlMjAxOSklMEEoMSUyQyUyMDE5JTJDJTIwOSk=",highlighted:`(<span class="hljs-number">1</span>, <span class="hljs-number">19</span>)
(<span class="hljs-number">1</span>, <span class="hljs-number">19</span>, <span class="hljs-number">9</span>)`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=m,e=p(),c(o.$$.fragment),f=p(),h=u("p"),h.innerHTML=k,A=p(),c(x.$$.fragment),C=p(),c(I.$$.fragment)},l(M){t=w(M,"P",{"data-svelte-h":!0}),g(t)!=="svelte-19verki"&&(t.innerHTML=m),e=r(M),j(o.$$.fragment,M),f=r(M),h=w(M,"P",{"data-svelte-h":!0}),g(h)!=="svelte-1y10l9j"&&(h.innerHTML=k),A=r(M),j(x.$$.fragment,M),C=r(M),j(I.$$.fragment,M)},m(M,d){a(M,t,d),a(M,e,d),y(o,M,d),a(M,f,d),a(M,h,d),a(M,A,d),y(x,M,d),a(M,C,d),y(I,M,d),$=!0},i(M){$||(i(o.$$.fragment,M),i(x.$$.fragment,M),i(I.$$.fragment,M),$=!0)},o(M){J(o.$$.fragment,M),J(x.$$.fragment,M),J(I.$$.fragment,M),$=!1},d(M){M&&(l(t),l(e),l(f),l(h),l(A),l(C)),T(o,M),T(x,M),T(I,M)}}}function rt(b){let t,m='首先，我們需要標記我們的輸入並將其傳遞給模型。這是完全按照<a href="/course/chapter2">Chapter 2</a>;我們使用 <strong>AutoXxx</strong> 類，然後在我們的示例中使用它們：',e,o,f,h,k="由於我們正在使用 <strong>AutoModelForTokenClassification</strong> 在這裡，我們為輸入序列中的每個標記獲得一組 logits：",A,x,C,I,$;return o=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JUb2tlbkNsYXNzaWZpY2F0aW9uJTBBJTBBbW9kZWxfY2hlY2twb2ludCUyMCUzRCUyMCUyMmRibWR6JTJGYmVydC1sYXJnZS1jYXNlZC1maW5ldHVuZWQtY29ubGwwMy1lbmdsaXNoJTIyJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2hlY2twb2ludCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclRva2VuQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NoZWNrcG9pbnQpJTBBJTBBZXhhbXBsZSUyMCUzRCUyMCUyMk15JTIwbmFtZSUyMGlzJTIwU3lsdmFpbiUyMGFuZCUyMEklMjB3b3JrJTIwYXQlMjBIdWdnaW5nJTIwRmFjZSUyMGluJTIwQnJvb2tseW4uJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKGV4YW1wbGUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForTokenClassification

model_checkpoint = <span class="hljs-string">&quot;dbmdz/bert-large-cased-finetuned-conll03-english&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = AutoModelForTokenClassification.from_pretrained(model_checkpoint)

example = <span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>
inputs = tokenizer(example, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
outputs = model(**inputs)`,wrap:!1}}),x=new U({props:{code:"cHJpbnQoaW5wdXRzJTVCJTIyaW5wdXRfaWRzJTIyJTVELnNoYXBlKSUwQXByaW50KG91dHB1dHMubG9naXRzLnNoYXBlKQ==",highlighted:`<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape)
<span class="hljs-built_in">print</span>(outputs.logits.shape)`,wrap:!1}}),I=new U({props:{code:"dG9yY2guU2l6ZSglNUIxJTJDJTIwMTklNUQpJTBBdG9yY2guU2l6ZSglNUIxJTJDJTIwMTklMkMlMjA5JTVEKQ==",highlighted:`torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">19</span>])
torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">19</span>, <span class="hljs-number">9</span>])`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=m,e=p(),c(o.$$.fragment),f=p(),h=u("p"),h.innerHTML=k,A=p(),c(x.$$.fragment),C=p(),c(I.$$.fragment)},l(M){t=w(M,"P",{"data-svelte-h":!0}),g(t)!=="svelte-19verki"&&(t.innerHTML=m),e=r(M),j(o.$$.fragment,M),f=r(M),h=w(M,"P",{"data-svelte-h":!0}),g(h)!=="svelte-1ipbram"&&(h.innerHTML=k),A=r(M),j(x.$$.fragment,M),C=r(M),j(I.$$.fragment,M)},m(M,d){a(M,t,d),a(M,e,d),y(o,M,d),a(M,f,d),a(M,h,d),a(M,A,d),y(x,M,d),a(M,C,d),y(I,M,d),$=!0},i(M){$||(i(o.$$.fragment,M),i(x.$$.fragment,M),i(I.$$.fragment,M),$=!0)},o(M){J(o.$$.fragment,M),J(x.$$.fragment,M),J(I.$$.fragment,M),$=!1},d(M){M&&(l(t),l(e),l(f),l(h),l(A),l(C)),T(o,M),T(x,M),T(I,M)}}}function Mt(b){let t,m;return t=new U({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFwcm9iYWJpbGl0aWVzJTIwJTNEJTIwdGYubWF0aC5zb2Z0bWF4KG91dHB1dHMubG9naXRzJTJDJTIwYXhpcyUzRC0xKSU1QjAlNUQlMEFwcm9iYWJpbGl0aWVzJTIwJTNEJTIwcHJvYmFiaWxpdGllcy5udW1weSgpLnRvbGlzdCgpJTBBcHJlZGljdGlvbnMlMjAlM0QlMjB0Zi5tYXRoLmFyZ21heChvdXRwdXRzLmxvZ2l0cyUyQyUyMGF4aXMlM0QtMSklNUIwJTVEJTBBcHJlZGljdGlvbnMlMjAlM0QlMjBwcmVkaWN0aW9ucy5udW1weSgpLnRvbGlzdCgpJTBBcHJpbnQocHJlZGljdGlvbnMp",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

probabilities = tf.math.softmax(outputs.logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
probabilities = probabilities.numpy().tolist()
predictions = tf.math.argmax(outputs.logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
predictions = predictions.numpy().tolist()
<span class="hljs-built_in">print</span>(predictions)`,wrap:!1}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function Jt(b){let t,m;return t=new U({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFwcm9iYWJpbGl0aWVzJTIwJTNEJTIwdG9yY2gubm4uZnVuY3Rpb25hbC5zb2Z0bWF4KG91dHB1dHMubG9naXRzJTJDJTIwZGltJTNELTEpJTVCMCU1RC50b2xpc3QoKSUwQXByZWRpY3Rpb25zJTIwJTNEJTIwb3V0cHV0cy5sb2dpdHMuYXJnbWF4KGRpbSUzRC0xKSU1QjAlNUQudG9saXN0KCklMEFwcmludChwcmVkaWN0aW9ucyk=",highlighted:`<span class="hljs-keyword">import</span> torch

probabilities = torch.nn.functional.softmax(outputs.logits, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].tolist()
predictions = outputs.logits.argmax(dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].tolist()
<span class="hljs-built_in">print</span>(predictions)`,wrap:!1}}),{c(){c(t.$$.fragment)},l(e){j(t.$$.fragment,e)},m(e,o){y(t,e,o),m=!0},i(e){m||(i(t.$$.fragment,e),m=!0)},o(e){J(t.$$.fragment,e),m=!1},d(e){T(t,e)}}}function it(b){let t,m,e,o,f,h,k,A,x,C,I,$,M='在本節中，我們將仔細研究 🤗 Transformers 中標記器的功能。到目前為止，我們只使用它們來標記輸入或將 ID 解碼迴文本，但是標記器——尤其是那些由 🤗 Tokenizers 庫支持的——可以做更多的事情。為了說明這些附加功能，我們將探索如何重現結果 <strong>token-classification</strong> （我們稱之為 <strong>ner</strong> ） 和 <strong>question-answering</strong> 我們第一次在<a href="/course/chapter1">Chapter 1</a>中遇到的管道.',d,v,un,V,ql='在接下來的討論中，我們會經常區分“慢”和“快”分詞器。慢速分詞器是在 🤗 Transformers 庫中用 Python 編寫的，而快速版本是由 🤗 分詞器提供的，它們是用 Rust 編寫的。如果你還記得在<a href="/course/chapter5/3">Chapter 5</a>中報告了快速和慢速分詞器對藥物審查數據集進行分詞所需的時間的這張表，您應該知道為什麼我們稱它們為“快”和“慢”：',wn,H,Pl='<thead><tr><th align="center">Fast tokenizer</th> <th align="center">Slow tokenizer</th> <th align="center"></th></tr></thead> <tbody><tr><td align="center"><code>batched=True</code></td> <td align="center">10.8s</td> <td align="center">4min41s</td></tr> <tr><td align="center"><code>batched=False</code></td> <td align="center">59.2s</td> <td align="center">5min3s</td></tr></tbody>',on,z,gn,X,Un,G,hn,D,Ol="分詞器的輸出不是簡單的 Python 字典；我們得到的實際上是一個特殊的 <strong>BatchEncoding</strong> 目的。它是字典的子類（這就是為什麼我們之前能夠毫無問題地索引到該結果中的原因），但具有主要由快速標記器使用的附加方法。",xn,Y,Kl="除了它們的並行化能力之外，快速標記器的關鍵功能是它們始終跟蹤最終標記來自的原始文本範圍——我們稱之為偏移映射.這反過來又解鎖了諸如將每個單詞映射到它生成的標記或將原始文本的每個字符映射到它內部的標記等功能，反之亦然。讓我們看一個例子：",bn,L,dn,F,sa="如前所述，我們得到一個 <strong>BatchEncoding</strong> 標記器輸出中的對象：",In,q,fn,P,na="由於 <strong>AutoTokenizer</strong> 類默認選擇快速標記器，我們可以使用附加方法 this <strong>BatchEncoding</strong> 對象提供。我們有兩種方法來檢查我們的分詞器是快的還是慢的。我們可以檢查 <strong>is_fast</strong> 的屬性 <strong>tokenizer</strong> ：",Cn,O,kn,K,$n,ss,la="或檢查我們的相同屬性 <strong>encoding</strong> ：",An,ns,Qn,ls,Bn,as,aa="讓我們看看快速標記器使我們能夠做什麼。首先，我們可以訪問令牌而無需將 ID 轉換回令牌：",Zn,ts,Nn,es,En,ps,ta="在這種情況下，索引 5 處的令牌是 <strong>##yl</strong> ，它是原始句子中“Sylvain”一詞的一部分。我們也可以使用 <strong>word_ids()</strong> 獲取每個標記來自的單詞索引的方法：",Sn,rs,zn,Ms,_n,Js,ea="我們可以看到分詞器的特殊標記 <strong>[CLS]</strong> 和 <strong>[SEP]</strong> 被映射到 <strong>None</strong> ，然後每個標記都映射到它起源的單詞。這對於確定一個標記是否在單詞的開頭或兩個標記是否在同一個單詞中特別有用。我們可以依靠 <strong>##</strong> 前綴，但它僅適用於類似 BERT 的分詞器；這種方法適用於任何類型的標記器，只要它是快速的。在下一章中，我們將看到如何使用此功能將每個單詞的標籤正確應用於命名實體識別 (NER) 和詞性 (POS) 標記等任務中的標記。我們還可以使用它來屏蔽來自屏蔽語言建模中來自同一單詞的所有標記（一種稱為全詞掩碼）。",Rn,_,Wn,is,pa="同樣，有一個 <strong>sentence_ids()</strong> 我們可以用來將標記映射到它來自的句子的方法（儘管在這種情況下， <strong>token_type_ids</strong> 分詞器返回的信息可以為我們提供相同的信息）。",vn,cs,ra="最後，我們可以將任何單詞或標記映射到原始文本中的字符，反之亦然，通過 <strong>word_to_chars()</strong> 或者 <strong>token_to_chars()</strong> 和 <strong>char_to_word()</strong> 或者 <strong>char_to_token()</strong> 方法。例如， <strong>word_ids()</strong> 方法告訴我們 <strong>##yl</strong> 是索引 3 處單詞的一部分，但它是句子中的哪個單詞？我們可以這樣發現：",Vn,js,Hn,ys,Xn,Ts,Ma="正如我們之前提到的，這一切都是由快速標記器跟蹤每個標記來自列表中的文本跨度這一事實提供支持的抵消.為了說明它們的用途，接下來我們將向您展示如何複製結果 <strong>token-classification</strong> 手動管道。",Gn,R,Dn,ms,Yn,us,Ja='在<a href="/course/chapter1">Chapter 1</a>我們第一次嘗試使用 NER——任務是識別文本的哪些部分對應於個人、地點或組織等實體——使用 🤗 Transformers <strong>pipeline()</strong> 功能。然後，在<a href="/course/chapter2">Chapter 2</a>，我們看到了管道如何將從原始文本中獲取預測所需的三個階段組合在一起：標記化、通過模型傳遞輸入和後處理。前兩步 <strong>token-classification</strong> 管道與任何其他管道相同，但後處理稍微複雜一些 - 讓我們看看如何！',Ln,Q,B,cn,ws,Fn,os,ia='首先，讓我們獲取一個標記分類管道，以便我們可以手動比較一些結果。默認使用的模型是<a href="https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english" rel="nofollow">dbmdz/bert-large-cased-finetuned-conll03-english</a>;它對句子執行 NER：',qn,gs,Pn,Us,On,hs,ca="該模型正確地將“Sylvain”生成的每個標記識別為一個人，將“Hugging Face”生成的每個標記識別為一個組織，將“Brooklyn”生成的標記識別為一個位置。我們還可以要求管道將對應於同一實體的令牌組合在一起：",Kn,xs,sl,bs,nl,ds,ja="<strong>aggregation_strategy</strong> 選擇將更改為每個分組實體計算的分數。和 <strong>simple</strong> 分數只是給定實體中每個標記的分數的平均值：例如，“Sylvain”的分數是我們在前面的示例中看到的標記分數的平均值 <strong>S</strong> , <strong>##yl</strong> , <strong>##va</strong> ， 和 <strong>##in</strong> .其他可用的策略是：",ll,Is,ya="<li><p><code>&quot;first&quot;</code>, 其中每個實體的分數是該實體的第一個標記的分數（因此對於“Sylvain”，它將是 0.993828，標記的分數)</p></li> <li><p><code>&quot;max&quot;</code>,其中每個實體的分數是該實體中標記的最大分數（因此對於“Hugging Face”，它將是 0.98879766，即“Face”的分數）</p></li> <li><p><code>&quot;average&quot;</code>, 其中每個實體的分數是組成該實體的單詞分數的平均值（因此對於“Sylvain”，與“simple”策略，但“Hugging Face”的得分為 0.9819，“Hugging”得分的平均值為 0.975，“Face”得分為 0.98879）</p></li>",al,fs,Ta="現在讓我們看看如何在不使用pipeline（）函數的情況下獲得這些結果！",tl,Cs,el,Z,N,jn,ks,ma="我們有一個包含 19 個標記的 1 個序列的批次，模型有 9 個不同的標籤，因此模型的輸出具有 1 x 19 x 9 的形狀。與文本分類管道一樣，我們使用 softmax 函數來轉換這些 logits到概率，我們採用 argmax 來獲得預測（請注意，我們可以在 logits 上採用 argmax，因為 softmax 不會改變順序）：",pl,E,S,yn,$s,rl,As,ua="<strong>model.config.id2label</strong> 屬性包含索引到標籤的映射，我們可以用它來理解預測：",Ml,Qs,Jl,Bs,il,Zs,wa="正如我們之前看到的，有 9 個標籤： <strong>O</strong> 是不在任何命名實體中的標記的標籤（它代表“外部”），然後我們為每種類型的實體（雜項、人員、組織和位置）提供兩個標籤。標籤 <strong>B-XXX</strong> 表示令牌在實體的開頭 <strong>XXX</strong> 和標籤 <strong>I-XXX</strong> 表示令牌在實體內 <strong>XXX</strong> .例如，在當前示例中，我們希望我們的模型對令牌進行分類 <strong>S</strong> 作為 <strong>B-PER</strong> （一個人實體的開始）和令牌 <strong>##yl</strong> , <strong>##va</strong> 和 <strong>##in</strong> 作為 <strong>I-PER</strong> （在個人實體內）",cl,Ns,oa="在這種情況下，您可能認為模型是錯誤的，因為它給出了標籤 <strong>I-PER</strong> 對所有這四個令牌，但這並不完全正確。實際上有兩種格式 <strong>B-</strong> 和 <strong>I-</strong> 標籤：IOB1和IOB2. IOB2 格式（下面粉紅色）是我們介紹的格式，而在 IOB1 格式（藍色）中，標籤以 <strong>B-</strong> 僅用於分隔相同類型的兩個相鄰實體。我們使用的模型在使用該格式的數據集上進行了微調，這就是它分配標籤的原因 <strong>I-PER</strong> 到 <strong>S</strong> 令牌。",jl,W,ga='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter6/IOB_versions.svg" alt="IOB1 vs IOB2 format"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter6/IOB_versions-dark.svg" alt="IOB1 vs IOB2 format"/>',yl,Es,Ua="了這張地圖，我們已經準備好（幾乎完全）重現第一個管道的結果——我們可以獲取每個未被歸類為的標記的分數和標籤 <strong>O</strong> ：",Tl,Ss,ml,zs,ul,_s,ha="這與我們之前的情況非常相似，只有一個例外：管道還為我們提供了有關 <strong>start</strong> 和 <strong>end</strong> 原始句子中的每個實體。這是我們的偏移映射將發揮作用的地方。要獲得偏移量，我們只需要設置 <strong>return_offsets_mapping=True</strong> 當我們將分詞器應用於我們的輸入時：",wl,Rs,ol,Ws,gl,vs,xa="每個元組是對應於每個標記的文本跨度，其中 <strong>(0, 0)</strong> 保留用於特殊令牌。我們之前看到索引 5 處的令牌是 <strong>##yl</strong> ， 其中有 <strong>(12, 14)</strong> 作為這裡的抵消。如果我們在示例中抓取相應的切片：",Ul,Vs,hl,Hs,ba="我們得到了正確的文本跨度，而沒有 <strong>##</strong> ：",xl,Xs,bl,Gs,da="使用這個，我們現在可以完成之前的結果：",dl,Ds,Il,Ys,fl,Ls,Ia="這和我們從第一個管道中得到的一樣！",Cl,Fs,kl,qs,fa="使用偏移量來確定每個實體的開始和結束鍵很方便，但該信息並不是絕對必要的。然而，當我們想要將實體組合在一起時，偏移量將為我們節省大量混亂的代碼。例如，如果我們想將令牌組合在一起 <strong>Hu</strong> , <strong>##gging</strong> ， 和 <strong>Face</strong> ，我們可以制定特殊的規則，說前兩個應該附加，同時刪除 <strong>##</strong> ，以及 <strong>Face</strong> 應該添加一個空格，因為它不以 <strong>##</strong> — 但這僅適用於這種特定類型的標記器。我們必須為 SentencePiece 或 Byte-Pair-Encoding 分詞器（本章稍後討論）。",$l,Ps,Ca="編寫另一組規則。使用偏移量，所有自定義代碼都消失了：我們可以在原始文本中獲取從第一個標記開始到最後一個標記結束的跨度。所以，在令牌的情況下 <strong>Hu</strong> , <strong>##gging</strong> ， 和 <strong>Face</strong> ，我們應該從字符 33（開始 <strong>Hu</strong> ) 並在字符 45 之前結束（結束 <strong>Face</strong> )：",Al,Os,Ql,Ks,Bl,sn,ka="為了編寫在對實體進行分組的同時對預測進行後處理的代碼，我們將連續並標記為的實體分組在一起 <strong>I-XXX</strong> ，除了第一個，可以標記為 <strong>B-XXX</strong> 或者 <strong>I-XXX</strong> （因此，當我們得到一個實體時，我們停止對實體進行分組 <strong>O</strong> ，一種新型實體，或 <strong>B-XXX</strong> 這告訴我們一個相同類型的實體正在啟動）：",Zl,nn,Nl,ln,$a="我們得到了與第二條管道相同的結果！",El,an,Sl,tn,Aa="這些偏移量非常有用的另一個任務示例是問答。深入研究這個管道，我們將在下一節中進行，也將使我們能夠了解 🤗 Transformers 庫中標記器的最後一個功能：當我們將輸入截斷為給定長度時處理溢出的標記。",zl,en,_l,mn,Rl;f=new Pa({props:{fw:b[0]}}),k=new Tn({props:{title:"快速標記器的特殊能力",local:"快速標記器的特殊能力",headingTag:"h1"}});const Qa=[st,Ka],pn=[];function Ba(s,n){return s[0]==="pt"?0:1}x=Ba(b),C=pn[x]=Qa[x](b),v=new Vl({props:{id:"g8quOxoqhHQ"}}),z=new Ll({props:{warning:!0,$$slots:{default:[nt]},$$scope:{ctx:b}}}),X=new Tn({props:{title:"批量編碼",local:"批量編碼",headingTag:"h2"}}),G=new Vl({props:{id:"3umI3tm27Vw"}}),L=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBZXhhbXBsZSUyMCUzRCUyMCUyMk15JTIwbmFtZSUyMGlzJTIwU3lsdmFpbiUyMGFuZCUyMEklMjB3b3JrJTIwYXQlMjBIdWdnaW5nJTIwRmFjZSUyMGluJTIwQnJvb2tseW4uJTIyJTBBZW5jb2RpbmclMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSklMEFwcmludCh0eXBlKGVuY29kaW5nKSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>)
example = <span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>
encoding = tokenizer(example)
<span class="hljs-built_in">print</span>(<span class="hljs-built_in">type</span>(encoding))`,wrap:!1}}),q=new U({props:{code:"JTNDY2xhc3MlMjAndHJhbnNmb3JtZXJzLnRva2VuaXphdGlvbl91dGlsc19iYXNlLkJhdGNoRW5jb2RpbmcnJTNF",highlighted:'&lt;<span class="hljs-keyword">class</span> <span class="hljs-string">&#x27;transformers.tokenization_utils_base.BatchEncoding&#x27;</span>&gt;',wrap:!1}}),O=new U({props:{code:"dG9rZW5pemVyLmlzX2Zhc3Q=",highlighted:"tokenizer.is_fast",wrap:!1}}),K=new U({props:{code:"VHJ1ZQ==",highlighted:'<span class="hljs-literal">True</span>',wrap:!1}}),ns=new U({props:{code:"ZW5jb2RpbmcuaXNfZmFzdA==",highlighted:"encoding.is_fast",wrap:!1}}),ls=new U({props:{code:"VHJ1ZQ==",highlighted:'<span class="hljs-literal">True</span>',wrap:!1}}),ts=new U({props:{code:"ZW5jb2RpbmcudG9rZW5zKCk=",highlighted:"encoding.tokens()",wrap:!1}}),es=new U({props:{code:"JTVCJyU1QkNMUyU1RCclMkMlMjAnTXknJTJDJTIwJ25hbWUnJTJDJTIwJ2lzJyUyQyUyMCdTJyUyQyUyMCclMjMlMjN5bCclMkMlMjAnJTIzJTIzdmEnJTJDJTIwJyUyMyUyM2luJyUyQyUyMCdhbmQnJTJDJTIwJ0knJTJDJTIwJ3dvcmsnJTJDJTIwJ2F0JyUyQyUyMCdIdSclMkMlMjAnJTIzJTIzZ2dpbmcnJTJDJTIwJ0ZhY2UnJTJDJTIwJ2luJyUyQyUwQSUyMCdCcm9va2x5biclMkMlMjAnLiclMkMlMjAnJTVCU0VQJTVEJyU1RA==",highlighted:`[<span class="hljs-string">&#x27;[CLS]&#x27;</span>, <span class="hljs-string">&#x27;My&#x27;</span>, <span class="hljs-string">&#x27;name&#x27;</span>, <span class="hljs-string">&#x27;is&#x27;</span>, <span class="hljs-string">&#x27;S&#x27;</span>, <span class="hljs-string">&#x27;##yl&#x27;</span>, <span class="hljs-string">&#x27;##va&#x27;</span>, <span class="hljs-string">&#x27;##in&#x27;</span>, <span class="hljs-string">&#x27;and&#x27;</span>, <span class="hljs-string">&#x27;I&#x27;</span>, <span class="hljs-string">&#x27;work&#x27;</span>, <span class="hljs-string">&#x27;at&#x27;</span>, <span class="hljs-string">&#x27;Hu&#x27;</span>, <span class="hljs-string">&#x27;##gging&#x27;</span>, <span class="hljs-string">&#x27;Face&#x27;</span>, <span class="hljs-string">&#x27;in&#x27;</span>,
 <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>]`,wrap:!1}}),rs=new U({props:{code:"ZW5jb2Rpbmcud29yZF9pZHMoKQ==",highlighted:"encoding.word_ids()",wrap:!1}}),Ms=new U({props:{code:"JTVCTm9uZSUyQyUyMDAlMkMlMjAxJTJDJTIwMiUyQyUyMDMlMkMlMjAzJTJDJTIwMyUyQyUyMDMlMkMlMjA0JTJDJTIwNSUyQyUyMDYlMkMlMjA3JTJDJTIwOCUyQyUyMDglMkMlMjA5JTJDJTIwMTAlMkMlMjAxMSUyQyUyMDEyJTJDJTIwTm9uZSU1RA==",highlighted:'[<span class="hljs-literal">None</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>, <span class="hljs-number">11</span>, <span class="hljs-number">12</span>, <span class="hljs-literal">None</span>]',wrap:!1}}),_=new Ll({props:{$$slots:{default:[lt]},$$scope:{ctx:b}}}),js=new U({props:{code:"c3RhcnQlMkMlMjBlbmQlMjAlM0QlMjBlbmNvZGluZy53b3JkX3RvX2NoYXJzKDMpJTBBZXhhbXBsZSU1QnN0YXJ0JTNBZW5kJTVE",highlighted:`start, end = encoding.word_to_chars(<span class="hljs-number">3</span>)
example[start:end]`,wrap:!1}}),ys=new U({props:{code:"U3lsdmFpbg==",highlighted:"Sylvain",wrap:!1}}),R=new Ll({props:{$$slots:{default:[at]},$$scope:{ctx:b}}}),ms=new Tn({props:{title:"在令牌分類管道內",local:"在令牌分類管道內",headingTag:"h2"}});const Za=[et,tt],rn=[];function Na(s,n){return s[0]==="pt"?0:1}Q=Na(b),B=rn[Q]=Za[Q](b),ws=new Tn({props:{title:"通過管道獲得基本結果",local:"通過管道獲得基本結果",headingTag:"h3"}}),gs=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdG9rZW5fY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMnRva2VuLWNsYXNzaWZpY2F0aW9uJTIyKSUwQXRva2VuX2NsYXNzaWZpZXIoJTIyTXklMjBuYW1lJTIwaXMlMjBTeWx2YWluJTIwYW5kJTIwSSUyMHdvcmslMjBhdCUyMEh1Z2dpbmclMjBGYWNlJTIwaW4lMjBCcm9va2x5bi4lMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

token_classifier = pipeline(<span class="hljs-string">&quot;token-classification&quot;</span>)
token_classifier(<span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>)`,wrap:!1}}),Us=new U({props:{code:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5MzgyOCUyQyUyMCdpbmRleCclM0ElMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ1MnJTJDJTIwJ3N0YXJ0JyUzQSUyMDExJTJDJTIwJ2VuZCclM0ElMjAxMiU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5ODE1NDc2JTJDJTIwJ2luZGV4JyUzQSUyMDUlMkMlMjAnd29yZCclM0ElMjAnJTIzJTIzeWwnJTJDJTIwJ3N0YXJ0JyUzQSUyMDEyJTJDJTIwJ2VuZCclM0ElMjAxNCU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5NTkwNzI1JTJDJTIwJ2luZGV4JyUzQSUyMDYlMkMlMjAnd29yZCclM0ElMjAnJTIzJTIzdmEnJTJDJTIwJ3N0YXJ0JyUzQSUyMDE0JTJDJTIwJ2VuZCclM0ElMjAxNiU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZScl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</span>: <span class="hljs-number">0.9993828</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">4</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;S&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">12</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99815476</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">5</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##yl&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">14</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99590725</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">6</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##va&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">14</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">16</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9992327</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">7</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##in&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97389334</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hu&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">35</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.976115</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">13</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##gging&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">35</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">40</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.98879766</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">14</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">41</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321055</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}]`,wrap:!1}}),xs=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBdG9rZW5fY2xhc3NpZmllciUyMCUzRCUyMHBpcGVsaW5lKCUyMnRva2VuLWNsYXNzaWZpY2F0aW9uJTIyJTJDJTIwYWdncmVnYXRpb25fc3RyYXRlZ3klM0QlMjJzaW1wbGUlMjIpJTBBdG9rZW5fY2xhc3NpZmllciglMjJNeSUyMG5hbWUlMjBpcyUyMFN5bHZhaW4lMjBhbmQlMjBJJTIwd29yayUyMGF0JTIwSHVnZ2luZyUyMEZhY2UlMjBpbiUyMEJyb29rbHluLiUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

token_classifier = pipeline(<span class="hljs-string">&quot;token-classification&quot;</span>, aggregation_strategy=<span class="hljs-string">&quot;simple&quot;</span>)
token_classifier(<span class="hljs-string">&quot;My name is Sylvain and I work at Hugging Face in Brooklyn.&quot;</span>)`,wrap:!1}}),bs=new U({props:{code:"JTVCJTdCJ2VudGl0eV9ncm91cCclM0ElMjAnUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5ODE2OTQlMkMlMjAnd29yZCclM0ElMjAnU3lsdmFpbiclMkMlMjAnc3RhcnQnJTNBJTIwMTElMkMlMjAnZW5kJyUzQSUyMDE4JTdEJTJDJTBBJTIwJTdCJ2VudGl0eV9ncm91cCclM0ElMjAnT1JHJyUyQyUyMCdzY29yZSclM0ElMjAwLjk3OTYwMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ0h1Z2dpbmclMjBGYWNlJyUyQyUyMCdzdGFydCclM0ElMjAzMyUyQyUyMCdlbmQnJTNBJTIwNDUlN0QlMkMlMEElMjAlN0InZW50aXR5X2dyb3VwJyUzQSUyMCdMT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",highlighted:`[{<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9981694</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Sylvain&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97960204</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321055</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}]`,wrap:!1}}),Cs=new Tn({props:{title:"從輸入到預測",local:"從輸入到預測",headingTag:"h3"}});const Ea=[rt,pt],Mn=[];function Sa(s,n){return s[0]==="pt"?0:1}Z=Sa(b),N=Mn[Z]=Ea[Z](b);const za=[Jt,Mt],Jn=[];function _a(s,n){return s[0]==="pt"?0:1}return E=_a(b),S=Jn[E]=za[E](b),$s=new U({props:{code:"JTVCMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDQlMkMlMjA0JTJDJTIwNCUyQyUyMDQlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwNiUyQyUyMDYlMkMlMjA2JTJDJTIwMCUyQyUyMDglMkMlMjAwJTJDJTIwMCU1RA==",highlighted:'[<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">6</span>, <span class="hljs-number">6</span>, <span class="hljs-number">6</span>, <span class="hljs-number">0</span>, <span class="hljs-number">8</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>]',wrap:!1}}),Qs=new U({props:{code:"bW9kZWwuY29uZmlnLmlkMmxhYmVs",highlighted:"model.config.id2label",wrap:!1}}),Bs=new U({props:{code:"JTdCMCUzQSUyMCdPJyUyQyUwQSUyMDElM0ElMjAnQi1NSVNDJyUyQyUwQSUyMDIlM0ElMjAnSS1NSVNDJyUyQyUwQSUyMDMlM0ElMjAnQi1QRVInJTJDJTBBJTIwNCUzQSUyMCdJLVBFUiclMkMlMEElMjA1JTNBJTIwJ0ItT1JHJyUyQyUwQSUyMDYlM0ElMjAnSS1PUkcnJTJDJTBBJTIwNyUzQSUyMCdCLUxPQyclMkMlMEElMjA4JTNBJTIwJ0ktTE9DJyU3RA==",highlighted:`{<span class="hljs-number">0</span>: <span class="hljs-string">&#x27;O&#x27;</span>,
 <span class="hljs-number">1</span>: <span class="hljs-string">&#x27;B-MISC&#x27;</span>,
 <span class="hljs-number">2</span>: <span class="hljs-string">&#x27;I-MISC&#x27;</span>,
 <span class="hljs-number">3</span>: <span class="hljs-string">&#x27;B-PER&#x27;</span>,
 <span class="hljs-number">4</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>,
 <span class="hljs-number">5</span>: <span class="hljs-string">&#x27;B-ORG&#x27;</span>,
 <span class="hljs-number">6</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>,
 <span class="hljs-number">7</span>: <span class="hljs-string">&#x27;B-LOC&#x27;</span>,
 <span class="hljs-number">8</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>}`,wrap:!1}}),Ss=new U({props:{code:"cmVzdWx0cyUyMCUzRCUyMCU1QiU1RCUwQXRva2VucyUyMCUzRCUyMGlucHV0cy50b2tlbnMoKSUwQSUwQWZvciUyMGlkeCUyQyUyMHByZWQlMjBpbiUyMGVudW1lcmF0ZShwcmVkaWN0aW9ucyklM0ElMEElMjAlMjAlMjAlMjBsYWJlbCUyMCUzRCUyMG1vZGVsLmNvbmZpZy5pZDJsYWJlbCU1QnByZWQlNUQlMEElMjAlMjAlMjAlMjBpZiUyMGxhYmVsJTIwISUzRCUyMCUyMk8lMjIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXN1bHRzLmFwcGVuZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJlbnRpdHklMjIlM0ElMjBsYWJlbCUyQyUyMCUyMnNjb3JlJTIyJTNBJTIwcHJvYmFiaWxpdGllcyU1QmlkeCU1RCU1QnByZWQlNUQlMkMlMjAlMjJ3b3JkJTIyJTNBJTIwdG9rZW5zJTVCaWR4JTVEJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUwQXByaW50KHJlc3VsdHMp",highlighted:`results = []
tokens = inputs.tokens()

<span class="hljs-keyword">for</span> idx, pred <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(predictions):
    label = model.config.id2label[pred]
    <span class="hljs-keyword">if</span> label != <span class="hljs-string">&quot;O&quot;</span>:
        results.append(
            {<span class="hljs-string">&quot;entity&quot;</span>: label, <span class="hljs-string">&quot;score&quot;</span>: probabilities[idx][pred], <span class="hljs-string">&quot;word&quot;</span>: tokens[idx]}
        )

<span class="hljs-built_in">print</span>(results)`,wrap:!1}}),zs=new U({props:{code:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5MzgyOCUyQyUyMCdpbmRleCclM0ElMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ1MnJTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk4MTU0NzYlMkMlMjAnaW5kZXgnJTNBJTIwNSUyQyUyMCd3b3JkJyUzQSUyMCclMjMlMjN5bCclN0QlMkMlMEElMjAlN0InZW50aXR5JyUzQSUyMCdJLVBFUiclMkMlMjAnc2NvcmUnJTNBJTIwMC45OTU5MDcyNSUyQyUyMCdpbmRleCclM0ElMjA2JTJDJTIwJ3dvcmQnJTNBJTIwJyUyMyUyM3ZhJyU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5OTIzMjclMkMlMjAnaW5kZXgnJTNBJTIwNyUyQyUyMCd3b3JkJyUzQSUyMCclMjMlMjNpbiclN0QlMkMlMEElMjAlN0InZW50aXR5JyUzQSUyMCdJLU9SRyclMkMlMjAnc2NvcmUnJTNBJTIwMC45NzM4OTMzNCUyQyUyMCdpbmRleCclM0ElMjAxMiUyQyUyMCd3b3JkJyUzQSUyMCdIdSclN0QlMkMlMEElMjAlN0InZW50aXR5JyUzQSUyMCdJLU9SRyclMkMlMjAnc2NvcmUnJTNBJTIwMC45NzYxMTUlMkMlMjAnaW5kZXgnJTNBJTIwMTMlMkMlMjAnd29yZCclM0ElMjAnJTIzJTIzZ2dpbmcnJTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1PUkcnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTg4Nzk3NjYlMkMlMjAnaW5kZXgnJTNBJTIwMTQlMkMlMjAnd29yZCclM0ElMjAnRmFjZSclN0QlMkMlMEElMjAlN0InZW50aXR5JyUzQSUyMCdJLUxPQyclMkMlMjAnc2NvcmUnJTNBJTIwMC45OTMyMTA1NSUyQyUyMCdpbmRleCclM0ElMjAxNiUyQyUyMCd3b3JkJyUzQSUyMCdCcm9va2x5biclN0QlNUQ=",highlighted:`[{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9993828</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">4</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;S&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99815476</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">5</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##yl&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99590725</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">6</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##va&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9992327</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">7</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##in&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97389334</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hu&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.976115</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">13</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##gging&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.98879766</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">14</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Face&#x27;</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321055</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>}]`,wrap:!1}}),Rs=new U({props:{code:"aW5wdXRzX3dpdGhfb2Zmc2V0cyUyMCUzRCUyMHRva2VuaXplcihleGFtcGxlJTJDJTIwcmV0dXJuX29mZnNldHNfbWFwcGluZyUzRFRydWUpJTBBaW5wdXRzX3dpdGhfb2Zmc2V0cyU1QiUyMm9mZnNldF9tYXBwaW5nJTIyJTVE",highlighted:`inputs_with_offsets = tokenizer(example, return_offsets_mapping=<span class="hljs-literal">True</span>)
inputs_with_offsets[<span class="hljs-string">&quot;offset_mapping&quot;</span>]`,wrap:!1}}),Ws=new U({props:{code:"JTVCKDAlMkMlMjAwKSUyQyUyMCgwJTJDJTIwMiklMkMlMjAoMyUyQyUyMDcpJTJDJTIwKDglMkMlMjAxMCklMkMlMjAoMTElMkMlMjAxMiklMkMlMjAoMTIlMkMlMjAxNCklMkMlMjAoMTQlMkMlMjAxNiklMkMlMjAoMTYlMkMlMjAxOCklMkMlMjAoMTklMkMlMjAyMiklMkMlMjAoMjMlMkMlMjAyNCklMkMlMjAoMjUlMkMlMjAyOSklMkMlMjAoMzAlMkMlMjAzMiklMkMlMEElMjAoMzMlMkMlMjAzNSklMkMlMjAoMzUlMkMlMjA0MCklMkMlMjAoNDElMkMlMjA0NSklMkMlMjAoNDYlMkMlMjA0OCklMkMlMjAoNDklMkMlMjA1NyklMkMlMjAoNTclMkMlMjA1OCklMkMlMjAoMCUyQyUyMDApJTVE",highlighted:`[(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>), (<span class="hljs-number">0</span>, <span class="hljs-number">2</span>), (<span class="hljs-number">3</span>, <span class="hljs-number">7</span>), (<span class="hljs-number">8</span>, <span class="hljs-number">10</span>), (<span class="hljs-number">11</span>, <span class="hljs-number">12</span>), (<span class="hljs-number">12</span>, <span class="hljs-number">14</span>), (<span class="hljs-number">14</span>, <span class="hljs-number">16</span>), (<span class="hljs-number">16</span>, <span class="hljs-number">18</span>), (<span class="hljs-number">19</span>, <span class="hljs-number">22</span>), (<span class="hljs-number">23</span>, <span class="hljs-number">24</span>), (<span class="hljs-number">25</span>, <span class="hljs-number">29</span>), (<span class="hljs-number">30</span>, <span class="hljs-number">32</span>),
 (<span class="hljs-number">33</span>, <span class="hljs-number">35</span>), (<span class="hljs-number">35</span>, <span class="hljs-number">40</span>), (<span class="hljs-number">41</span>, <span class="hljs-number">45</span>), (<span class="hljs-number">46</span>, <span class="hljs-number">48</span>), (<span class="hljs-number">49</span>, <span class="hljs-number">57</span>), (<span class="hljs-number">57</span>, <span class="hljs-number">58</span>), (<span class="hljs-number">0</span>, <span class="hljs-number">0</span>)]`,wrap:!1}}),Vs=new U({props:{code:"ZXhhbXBsZSU1QjEyJTNBMTQlNUQ=",highlighted:'example[<span class="hljs-number">12</span>:<span class="hljs-number">14</span>]',wrap:!1}}),Xs=new U({props:{code:"eWw=",highlighted:"yl",wrap:!1}}),Ds=new U({props:{code:"cmVzdWx0cyUyMCUzRCUyMCU1QiU1RCUwQWlucHV0c193aXRoX29mZnNldHMlMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSUyQyUyMHJldHVybl9vZmZzZXRzX21hcHBpbmclM0RUcnVlKSUwQXRva2VucyUyMCUzRCUyMGlucHV0c193aXRoX29mZnNldHMudG9rZW5zKCklMEFvZmZzZXRzJTIwJTNEJTIwaW5wdXRzX3dpdGhfb2Zmc2V0cyU1QiUyMm9mZnNldF9tYXBwaW5nJTIyJTVEJTBBJTBBZm9yJTIwaWR4JTJDJTIwcHJlZCUyMGluJTIwZW51bWVyYXRlKHByZWRpY3Rpb25zKSUzQSUwQSUyMCUyMCUyMCUyMGxhYmVsJTIwJTNEJTIwbW9kZWwuY29uZmlnLmlkMmxhYmVsJTVCcHJlZCU1RCUwQSUyMCUyMCUyMCUyMGlmJTIwbGFiZWwlMjAhJTNEJTIwJTIyTyUyMiUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN0YXJ0JTJDJTIwZW5kJTIwJTNEJTIwb2Zmc2V0cyU1QmlkeCU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJlc3VsdHMuYXBwZW5kKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMmVudGl0eSUyMiUzQSUyMGxhYmVsJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyc2NvcmUlMjIlM0ElMjBwcm9iYWJpbGl0aWVzJTVCaWR4JTVEJTVCcHJlZCU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMndvcmQlMjIlM0ElMjB0b2tlbnMlNUJpZHglNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUwQXByaW50KHJlc3VsdHMp",highlighted:`results = []
inputs_with_offsets = tokenizer(example, return_offsets_mapping=<span class="hljs-literal">True</span>)
tokens = inputs_with_offsets.tokens()
offsets = inputs_with_offsets[<span class="hljs-string">&quot;offset_mapping&quot;</span>]

<span class="hljs-keyword">for</span> idx, pred <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(predictions):
    label = model.config.id2label[pred]
    <span class="hljs-keyword">if</span> label != <span class="hljs-string">&quot;O&quot;</span>:
        start, end = offsets[idx]
        results.append(
            {
                <span class="hljs-string">&quot;entity&quot;</span>: label,
                <span class="hljs-string">&quot;score&quot;</span>: probabilities[idx][pred],
                <span class="hljs-string">&quot;word&quot;</span>: tokens[idx],
                <span class="hljs-string">&quot;start&quot;</span>: start,
                <span class="hljs-string">&quot;end&quot;</span>: end,
            }
        )

<span class="hljs-built_in">print</span>(results)`,wrap:!1}}),Ys=new U({props:{code:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTI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pbmRleCclM0ElMjAxMyUyQyUyMCd3b3JkJyUzQSUyMCclMjMlMjNnZ2luZyclMkMlMjAnc3RhcnQnJTNBJTIwMzUlMkMlMjAnZW5kJyUzQSUyMDQwJTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1PUkcnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTg4Nzk3NjYlMkMlMjAnaW5kZXgnJTNBJTIwMTQlMkMlMjAnd29yZCclM0ElMjAnRmFjZSclMkMlMjAnc3RhcnQnJTNBJTIwNDElMkMlMjAnZW5kJyUzQSUyMDQ1JTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1MT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnaW5kZXgnJTNBJTIwMTYlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",highlighted:`[{<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9993828</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">4</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;S&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">12</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99815476</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">5</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##yl&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">14</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99590725</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">6</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##va&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">14</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">16</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9992327</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">7</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##in&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97389334</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">12</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hu&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">35</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.976115</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">13</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;##gging&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">35</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">40</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.98879766</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">14</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">41</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>},
 {<span class="hljs-string">&#x27;entity&#x27;</span>: <span class="hljs-string">&#x27;I-LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321055</span>, <span class="hljs-string">&#x27;index&#x27;</span>: <span class="hljs-number">16</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}]`,wrap:!1}}),Fs=new Tn({props:{title:"分組實體",local:"分組實體",headingTag:"h3"}}),Os=new U({props:{code:"ZXhhbXBsZSU1QjMzJTNBNDUlNUQ=",highlighted:'example[<span class="hljs-number">33</span>:<span class="hljs-number">45</span>]',wrap:!1}}),Ks=new U({props:{code:"SHVnZ2luZyUyMEZhY2U=",highlighted:"Hugging Face",wrap:!1}}),nn=new U({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBcmVzdWx0cyUyMCUzRCUyMCU1QiU1RCUwQWlucHV0c193aXRoX29mZnNldHMlMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSUyQyUyMHJldHVybl9vZmZz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yb3VwJTIyJTNBJTIwbGFiZWwlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzY29yZSUyMiUzQSUyMHNjb3JlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyd29yZCUyMiUzQSUyMHdvcmQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGlkeCUyMCUyQiUzRCUyMDElMEElMEFwcmludChyZXN1bHRzKQ==",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

results = []
inputs_with_offsets = tokenizer(example, return_offsets_mapping=<span class="hljs-literal">True</span>)
tokens = inputs_with_offsets.tokens()
offsets = inputs_with_offsets[<span class="hljs-string">&quot;offset_mapping&quot;</span>]

idx = <span class="hljs-number">0</span>
<span class="hljs-keyword">while</span> idx &lt; <span class="hljs-built_in">len</span>(predictions):
    pred = predictions[idx]
    label = model.config.id2label[pred]
    <span class="hljs-keyword">if</span> label != <span class="hljs-string">&quot;O&quot;</span>:
        <span class="hljs-comment"># Remove the B- or I-</span>
        label = label[<span class="hljs-number">2</span>:]
        start, _ = offsets[idx]

        <span class="hljs-comment"># Grab all the tokens labeled with I-label</span>
        all_scores = []
        <span class="hljs-keyword">while</span> (
            idx &lt; <span class="hljs-built_in">len</span>(predictions)
            <span class="hljs-keyword">and</span> model.config.id2label[predictions[idx]] == <span class="hljs-string">f&quot;I-<span class="hljs-subst">{label}</span>&quot;</span>
        ):
            all_scores.append(probabilities[idx][pred])
            _, end = offsets[idx]
            idx += <span class="hljs-number">1</span>

        <span class="hljs-comment"># The score is the mean of all the scores of the tokens in that grouped entity</span>
        score = np.mean(all_scores).item()
        word = example[start:end]
        results.append(
            {
                <span class="hljs-string">&quot;entity_group&quot;</span>: label,
                <span class="hljs-string">&quot;score&quot;</span>: score,
                <span class="hljs-string">&quot;word&quot;</span>: word,
                <span class="hljs-string">&quot;start&quot;</span>: start,
                <span class="hljs-string">&quot;end&quot;</span>: end,
            }
        )
    idx += <span class="hljs-number">1</span>

<span class="hljs-built_in">print</span>(results)`,wrap:!1}}),an=new U({props:{code:"JTVCJTdCJ2VudGl0eV9ncm91cCclM0ElMjAnUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5ODE2OTQlMkMlMjAnd29yZCclM0ElMjAnU3lsdmFpbiclMkMlMjAnc3RhcnQnJTNBJTIwMTElMkMlMjAnZW5kJyUzQSUyMDE4JTdEJTJDJTBBJTIwJTdCJ2VudGl0eV9ncm91cCclM0ElMjAnT1JHJyUyQyUyMCdzY29yZSclM0ElMjAwLjk3OTYwMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ0h1Z2dpbmclMjBGYWNlJyUyQyUyMCdzdGFydCclM0ElMjAzMyUyQyUyMCdlbmQnJTNBJTIwNDUlN0QlMkMlMEElMjAlN0InZW50aXR5X2dyb3VwJyUzQSUyMCdMT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",highlighted:`[{<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;PER&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9981694</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Sylvain&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">11</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">18</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;ORG&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97960204</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Hugging Face&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">33</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">45</span>},
 {<span class="hljs-string">&#x27;entity_group&#x27;</span>: <span class="hljs-string">&#x27;LOC&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.99321055</span>, <span class="hljs-string">&#x27;word&#x27;</span>: <span class="hljs-string">&#x27;Brooklyn&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">49</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">57</span>}]`,wrap:!1}}),en=new Oa({props:{source:"https://github.com/huggingface/course/blob/main/chapters/zh-TW/chapter6/3.mdx"}}),{c(){t=u("meta"),m=p(),e=u("p"),o=p(),c(f.$$.fragment),h=p(),c(k.$$.fragment),A=p(),C.c(),I=p(),$=u("p"),$.innerHTML=M,d=p(),c(v.$$.fragment),un=p(),V=u("p"),V.innerHTML=ql,wn=p(),H=u("table"),H.innerHTML=Pl,on=p(),c(z.$$.fragment),gn=p(),c(X.$$.fragment),Un=p(),c(G.$$.fragment),hn=p(),D=u("p"),D.innerHTML=Ol,xn=p(),Y=u("p"),Y.textContent=Kl,bn=p(),c(L.$$.fragment),dn=p(),F=u("p"),F.innerHTML=sa,In=p(),c(q.$$.fragment),fn=p(),P=u("p"),P.innerHTML=na,Cn=p(),c(O.$$.fragment),kn=p(),c(K.$$.fragment),$n=p(),ss=u("p"),ss.innerHTML=la,An=p(),c(ns.$$.fragment),Qn=p(),c(ls.$$.fragment),Bn=p(),as=u("p"),as.textContent=aa,Zn=p(),c(ts.$$.fragment),Nn=p(),c(es.$$.fragment),En=p(),ps=u("p"),ps.innerHTML=ta,Sn=p(),c(rs.$$.fragment),zn=p(),c(Ms.$$.fragment),_n=p(),Js=u("p"),Js.innerHTML=ea,Rn=p(),c(_.$$.fragment),Wn=p(),is=u("p"),is.innerHTML=pa,vn=p(),cs=u("p"),cs.innerHTML=ra,Vn=p(),c(js.$$.fragment),Hn=p(),c(ys.$$.fragment),Xn=p(),Ts=u("p"),Ts.innerHTML=Ma,Gn=p(),c(R.$$.fragment),Dn=p(),c(ms.$$.fragment),Yn=p(),us=u("p"),us.innerHTML=Ja,Ln=p(),B.c(),cn=p(),c(ws.$$.fragment),Fn=p(),os=u("p"),os.innerHTML=ia,qn=p(),c(gs.$$.fragment),Pn=p(),c(Us.$$.fragment),On=p(),hs=u("p"),hs.textContent=ca,Kn=p(),c(xs.$$.fragment),sl=p(),c(bs.$$.fragment),nl=p(),ds=u("p"),ds.innerHTML=ja,ll=p(),Is=u("ul"),Is.innerHTML=ya,al=p(),fs=u("p"),fs.textContent=Ta,tl=p(),c(Cs.$$.fragment),el=p(),N.c(),jn=p(),ks=u("p"),ks.textContent=ma,pl=p(),S.c(),yn=p(),c($s.$$.fragment),rl=p(),As=u("p"),As.innerHTML=ua,Ml=p(),c(Qs.$$.fragment),Jl=p(),c(Bs.$$.fragment),il=p(),Zs=u("p"),Zs.innerHTML=wa,cl=p(),Ns=u("p"),Ns.innerHTML=oa,jl=p(),W=u("div"),W.innerHTML=ga,yl=p(),Es=u("p"),Es.innerHTML=Ua,Tl=p(),c(Ss.$$.fragment),ml=p(),c(zs.$$.fragment),ul=p(),_s=u("p"),_s.innerHTML=ha,wl=p(),c(Rs.$$.fragment),ol=p(),c(Ws.$$.fragment),gl=p(),vs=u("p"),vs.innerHTML=xa,Ul=p(),c(Vs.$$.fragment),hl=p(),Hs=u("p"),Hs.innerHTML=ba,xl=p(),c(Xs.$$.fragment),bl=p(),Gs=u("p"),Gs.textContent=da,dl=p(),c(Ds.$$.fragment),Il=p(),c(Ys.$$.fragment),fl=p(),Ls=u("p"),Ls.textContent=Ia,Cl=p(),c(Fs.$$.fragment),kl=p(),qs=u("p"),qs.innerHTML=fa,$l=p(),Ps=u("p"),Ps.innerHTML=Ca,Al=p(),c(Os.$$.fragment),Ql=p(),c(Ks.$$.fragment),Bl=p(),sn=u("p"),sn.innerHTML=ka,Zl=p(),c(nn.$$.fragment),Nl=p(),ln=u("p"),ln.textContent=$a,El=p(),c(an.$$.fragment),Sl=p(),tn=u("p"),tn.textContent=Aa,zl=p(),c(en.$$.fragment),_l=p(),mn=u("p"),this.h()},l(s){const n=Fa("svelte-u9bgzb",document.head);t=w(n,"META",{name:!0,content:!0}),n.forEach(l),m=r(s),e=w(s,"P",{}),Ha(e).forEach(l),o=r(s),j(f.$$.fragment,s),h=r(s),j(k.$$.fragment,s),A=r(s),C.l(s),I=r(s),$=w(s,"P",{"data-svelte-h":!0}),g($)!=="svelte-1g5reet"&&($.innerHTML=M),d=r(s),j(v.$$.fragment,s),un=r(s),V=w(s,"P",{"data-svelte-h":!0}),g(V)!=="svelte-10hr723"&&(V.innerHTML=ql),wn=r(s),H=w(s,"TABLE",{"data-svelte-h":!0}),g(H)!=="svelte-1hjgutj"&&(H.innerHTML=Pl),on=r(s),j(z.$$.fragment,s),gn=r(s),j(X.$$.fragment,s),Un=r(s),j(G.$$.fragment,s),hn=r(s),D=w(s,"P",{"data-svelte-h":!0}),g(D)!=="svelte-1d3tcs5"&&(D.innerHTML=Ol),xn=r(s),Y=w(s,"P",{"data-svelte-h":!0}),g(Y)!=="svelte-15mrtyn"&&(Y.textContent=Kl),bn=r(s),j(L.$$.fragment,s),dn=r(s),F=w(s,"P",{"data-svelte-h":!0}),g(F)!=="svelte-ktpggn"&&(F.innerHTML=sa),In=r(s),j(q.$$.fragment,s),fn=r(s),P=w(s,"P",{"data-svelte-h":!0}),g(P)!=="svelte-1arss7v"&&(P.innerHTML=na),Cn=r(s),j(O.$$.fragment,s),kn=r(s),j(K.$$.fragment,s),$n=r(s),ss=w(s,"P",{"data-svelte-h":!0}),g(ss)!=="svelte-1ts2cbi"&&(ss.innerHTML=la),An=r(s),j(ns.$$.fragment,s),Qn=r(s),j(ls.$$.fragment,s),Bn=r(s),as=w(s,"P",{"data-svelte-h":!0}),g(as)!=="svelte-u7zusu"&&(as.textContent=aa),Zn=r(s),j(ts.$$.fragment,s),Nn=r(s),j(es.$$.fragment,s),En=r(s),ps=w(s,"P",{"data-svelte-h":!0}),g(ps)!=="svelte-u8rtbu"&&(ps.innerHTML=ta),Sn=r(s),j(rs.$$.fragment,s),zn=r(s),j(Ms.$$.fragment,s),_n=r(s),Js=w(s,"P",{"data-svelte-h":!0}),g(Js)!=="svelte-rcox08"&&(Js.innerHTML=ea),Rn=r(s),j(_.$$.fragment,s),Wn=r(s),is=w(s,"P",{"data-svelte-h":!0}),g(is)!=="svelte-14wpzgy"&&(is.innerHTML=pa),vn=r(s),cs=w(s,"P",{"data-svelte-h":!0}),g(cs)!=="svelte-1n661ij"&&(cs.innerHTML=ra),Vn=r(s),j(js.$$.fragment,s),Hn=r(s),j(ys.$$.fragment,s),Xn=r(s),Ts=w(s,"P",{"data-svelte-h":!0}),g(Ts)!=="svelte-1mkjom1"&&(Ts.innerHTML=Ma),Gn=r(s),j(R.$$.fragment,s),Dn=r(s),j(ms.$$.fragment,s),Yn=r(s),us=w(s,"P",{"data-svelte-h":!0}),g(us)!=="svelte-6ktmh8"&&(us.innerHTML=Ja),Ln=r(s),B.l(s),cn=r(s),j(ws.$$.fragment,s),Fn=r(s),os=w(s,"P",{"data-svelte-h":!0}),g(os)!=="svelte-1im11dp"&&(os.innerHTML=ia),qn=r(s),j(gs.$$.fragment,s),Pn=r(s),j(Us.$$.fragment,s),On=r(s),hs=w(s,"P",{"data-svelte-h":!0}),g(hs)!=="svelte-15ear77"&&(hs.textContent=ca),Kn=r(s),j(xs.$$.fragment,s),sl=r(s),j(bs.$$.fragment,s),nl=r(s),ds=w(s,"P",{"data-svelte-h":!0}),g(ds)!=="svelte-4ur5va"&&(ds.innerHTML=ja),ll=r(s),Is=w(s,"UL",{"data-svelte-h":!0}),g(Is)!=="svelte-k9teo1"&&(Is.innerHTML=ya),al=r(s),fs=w(s,"P",{"data-svelte-h":!0}),g(fs)!=="svelte-lcrtez"&&(fs.textContent=Ta),tl=r(s),j(Cs.$$.fragment,s),el=r(s),N.l(s),jn=r(s),ks=w(s,"P",{"data-svelte-h":!0}),g(ks)!=="svelte-7jn4qb"&&(ks.textContent=ma),pl=r(s),S.l(s),yn=r(s),j($s.$$.fragment,s),rl=r(s),As=w(s,"P",{"data-svelte-h":!0}),g(As)!=="svelte-1aurjsy"&&(As.innerHTML=ua),Ml=r(s),j(Qs.$$.fragment,s),Jl=r(s),j(Bs.$$.fragment,s),il=r(s),Zs=w(s,"P",{"data-svelte-h":!0}),g(Zs)!=="svelte-oijkbh"&&(Zs.innerHTML=wa),cl=r(s),Ns=w(s,"P",{"data-svelte-h":!0}),g(Ns)!=="svelte-1rf37fz"&&(Ns.innerHTML=oa),jl=r(s),W=w(s,"DIV",{class:!0,"data-svelte-h":!0}),g(W)!=="svelte-qf2tof"&&(W.innerHTML=ga),yl=r(s),Es=w(s,"P",{"data-svelte-h":!0}),g(Es)!=="svelte-1yj9z4d"&&(Es.innerHTML=Ua),Tl=r(s),j(Ss.$$.fragment,s),ml=r(s),j(zs.$$.fragment,s),ul=r(s),_s=w(s,"P",{"data-svelte-h":!0}),g(_s)!=="svelte-1etk3l8"&&(_s.innerHTML=ha),wl=r(s),j(Rs.$$.fragment,s),ol=r(s),j(Ws.$$.fragment,s),gl=r(s),vs=w(s,"P",{"data-svelte-h":!0}),g(vs)!=="svelte-1kkevkc"&&(vs.innerHTML=xa),Ul=r(s),j(Vs.$$.fragment,s),hl=r(s),Hs=w(s,"P",{"data-svelte-h":!0}),g(Hs)!=="svelte-1tm0fsv"&&(Hs.innerHTML=ba),xl=r(s),j(Xs.$$.fragment,s),bl=r(s),Gs=w(s,"P",{"data-svelte-h":!0}),g(Gs)!=="svelte-y8armr"&&(Gs.textContent=da),dl=r(s),j(Ds.$$.fragment,s),Il=r(s),j(Ys.$$.fragment,s),fl=r(s),Ls=w(s,"P",{"data-svelte-h":!0}),g(Ls)!=="svelte-1dhas60"&&(Ls.textContent=Ia),Cl=r(s),j(Fs.$$.fragment,s),kl=r(s),qs=w(s,"P",{"data-svelte-h":!0}),g(qs)!=="svelte-a15u7q"&&(qs.innerHTML=fa),$l=r(s),Ps=w(s,"P",{"data-svelte-h":!0}),g(Ps)!=="svelte-ry0eu"&&(Ps.innerHTML=Ca),Al=r(s),j(Os.$$.fragment,s),Ql=r(s),j(Ks.$$.fragment,s),Bl=r(s),sn=w(s,"P",{"data-svelte-h":!0}),g(sn)!=="svelte-1j3pxar"&&(sn.innerHTML=ka),Zl=r(s),j(nn.$$.fragment,s),Nl=r(s),ln=w(s,"P",{"data-svelte-h":!0}),g(ln)!=="svelte-1jjeu46"&&(ln.textContent=$a),El=r(s),j(an.$$.fragment,s),Sl=r(s),tn=w(s,"P",{"data-svelte-h":!0}),g(tn)!=="svelte-kqfyot"&&(tn.textContent=Aa),zl=r(s),j(en.$$.fragment,s),_l=r(s),mn=w(s,"P",{}),Ha(mn).forEach(l),this.h()},h(){Yl(t,"name","hf:doc:metadata"),Yl(t,"content",ct),Yl(W,"class","flex justify-center")},m(s,n){qa(document.head,t),a(s,m,n),a(s,e,n),a(s,o,n),y(f,s,n),a(s,h,n),y(k,s,n),a(s,A,n),pn[x].m(s,n),a(s,I,n),a(s,$,n),a(s,d,n),y(v,s,n),a(s,un,n),a(s,V,n),a(s,wn,n),a(s,H,n),a(s,on,n),y(z,s,n),a(s,gn,n),y(X,s,n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a(s,gl,n),a(s,vs,n),a(s,Ul,n),y(Vs,s,n),a(s,hl,n),a(s,Hs,n),a(s,xl,n),y(Xs,s,n),a(s,bl,n),a(s,Gs,n),a(s,dl,n),y(Ds,s,n),a(s,Il,n),y(Ys,s,n),a(s,fl,n),a(s,Ls,n),a(s,Cl,n),y(Fs,s,n),a(s,kl,n),a(s,qs,n),a(s,$l,n),a(s,Ps,n),a(s,Al,n),y(Os,s,n),a(s,Ql,n),y(Ks,s,n),a(s,Bl,n),a(s,sn,n),a(s,Zl,n),y(nn,s,n),a(s,Nl,n),a(s,ln,n),a(s,El,n),y(an,s,n),a(s,Sl,n),a(s,tn,n),a(s,zl,n),y(en,s,n),a(s,_l,n),a(s,mn,n),Rl=!0},p(s,[n]){const Ra={};n&1&&(Ra.fw=s[0]),f.$set(Ra);let Hl=x;x=Ba(s),x!==Hl&&(vl(),J(pn[Hl],1,1,()=>{pn[Hl]=null}),Wl(),C=pn[x],C||(C=pn[x]=Qa[x](s),C.c()),i(C,1),C.m(I.parentNode,I));const Wa={};n&2&&(Wa.$$scope={dirty:n,ctx:s}),z.$set(Wa);const va={};n&2&&(va.$$scope={dirty:n,ctx:s}),_.$set(va);const Va={};n&2&&(Va.$$scope={dirty:n,ctx:s}),R.$set(Va);let Xl=Q;Q=Na(s),Q!==Xl&&(vl(),J(rn[Xl],1,1,()=>{rn[Xl]=null}),Wl(),B=rn[Q],B||(B=rn[Q]=Za[Q](s),B.c()),i(B,1),B.m(cn.parentNode,cn));let Gl=Z;Z=Sa(s),Z!==Gl&&(vl(),J(Mn[Gl],1,1,()=>{Mn[Gl]=null}),Wl(),N=Mn[Z],N||(N=Mn[Z]=Ea[Z](s),N.c()),i(N,1),N.m(jn.parentNode,jn));let Dl=E;E=_a(s),E!==Dl&&(vl(),J(Jn[Dl],1,1,()=>{Jn[Dl]=null}),Wl(),S=Jn[E],S||(S=Jn[E]=za[E](s),S.c()),i(S,1),S.m(yn.parentNode,yn))},i(s){Rl||(i(f.$$.fragment,s),i(k.$$.fragment,s),i(C),i(v.$$.fragment,s),i(z.$$.fragment,s),i(X.$$.fragment,s),i(G.$$.fragment,s),i(L.$$.fragment,s),i(q.$$.fragment,s),i(O.$$.fragment,s),i(K.$$.fragment,s),i(ns.$$.fragment,s),i(ls.$$.fragment,s),i(ts.$$.fragment,s),i(es.$$.fragment,s),i(rs.$$.fragment,s),i(Ms.$$.fragment,s),i(_.$$.fragment,s),i(js.$$.fragment,s),i(ys.$$.fragment,s),i(R.$$.fragment,s),i(ms.$$.fragment,s),i(B),i(ws.$$.fragment,s),i(gs.$$.fragment,s),i(Us.$$.fragment,s),i(xs.$$.fragment,s),i(bs.$$.fragment,s),i(Cs.$$.fragment,s),i(N),i(S),i($s.$$.fragment,s),i(Qs.$$.fragment,s),i(Bs.$$.fragment,s),i(Ss.$$.fragment,s),i(zs.$$.fragment,s),i(Rs.$$.fragment,s),i(Ws.$$.fragment,s),i(Vs.$$.fragment,s),i(Xs.$$.fragment,s),i(Ds.$$.fragment,s),i(Ys.$$.fragment,s),i(Fs.$$.fragment,s),i(Os.$$.fragment,s),i(Ks.$$.fragment,s),i(nn.$$.fragment,s),i(an.$$.fragment,s),i(en.$$.fragment,s),Rl=!0)},o(s){J(f.$$.fragment,s),J(k.$$.fragment,s),J(C),J(v.$$.fragment,s),J(z.$$.fragment,s),J(X.$$.fragment,s),J(G.$$.fragment,s),J(L.$$.fragment,s),J(q.$$.fragment,s),J(O.$$.fragment,s),J(K.$$.fragment,s),J(ns.$$.fragment,s),J(ls.$$.fragment,s),J(ts.$$.fragment,s),J(es.$$.fragment,s),J(rs.$$.fragment,s),J(Ms.$$.fragment,s),J(_.$$.fragment,s),J(js.$$.fragment,s),J(ys.$$.fragment,s),J(R.$$.fragment,s),J(ms.$$.fragment,s),J(B),J(ws.$$.fragment,s),J(gs.$$.fragment,s),J(Us.$$.fragment,s),J(xs.$$.fragment,s),J(bs.$$.fragment,s),J(Cs.$$.fragment,s),J(N),J(S),J($s.$$.fragment,s),J(Qs.$$.fragment,s),J(Bs.$$.fragment,s),J(Ss.$$.fragment,s),J(zs.$$.fragment,s),J(Rs.$$.fragment,s),J(Ws.$$.fragment,s),J(Vs.$$.fragment,s),J(Xs.$$.fragment,s),J(Ds.$$.fragment,s),J(Ys.$$.fragment,s),J(Fs.$$.fragment,s),J(Os.$$.fragment,s),J(Ks.$$.fragment,s),J(nn.$$.fragment,s),J(an.$$.fragment,s),J(en.$$.fragment,s),Rl=!1},d(s){s&&(l(m),l(e),l(o),l(h),l(A),l(I),l($),l(d),l(un),l(V),l(wn),l(H),l(on),l(gn),l(Un),l(hn),l(D),l(xn),l(Y),l(bn),l(dn),l(F),l(In),l(fn),l(P),l(Cn),l(kn),l($n),l(ss),l(An),l(Qn),l(Bn),l(as),l(Zn),l(Nn),l(En),l(ps),l(Sn),l(zn),l(_n),l(Js),l(Rn),l(Wn),l(is),l(vn),l(cs),l(Vn),l(Hn),l(Xn),l(Ts),l(Gn),l(Dn),l(Yn),l(us),l(Ln),l(cn),l(Fn),l(os),l(qn),l(Pn),l(On),l(hs),l(Kn),l(sl),l(nl),l(ds),l(ll),l(Is),l(al),l(fs),l(tl),l(el),l(jn),l(ks),l(pl),l(yn),l(rl),l(As),l(Ml),l(Jl),l(il),l(Zs),l(cl),l(Ns),l(jl),l(W),l(yl),l(Es),l(Tl),l(ml),l(ul),l(_s),l(wl),l(ol),l(gl),l(vs),l(Ul),l(hl),l(Hs),l(xl),l(bl),l(Gs),l(dl),l(Il),l(fl),l(Ls),l(Cl),l(kl),l(qs),l($l),l(Ps),l(Al),l(Ql),l(Bl),l(sn),l(Zl),l(Nl),l(ln),l(El),l(Sl),l(tn),l(zl),l(_l),l(mn)),l(t),T(f,s),T(k,s),pn[x].d(s),T(v,s),T(z,s),T(X,s),T(G,s),T(L,s),T(q,s),T(O,s),T(K,s),T(ns,s),T(ls,s),T(ts,s),T(es,s),T(rs,s),T(Ms,s),T(_,s),T(js,s),T(ys,s),T(R,s),T(ms,s),rn[Q].d(s),T(ws,s),T(gs,s),T(Us,s),T(xs,s),T(bs,s),T(Cs,s),Mn[Z].d(s),Jn[E].d(s),T($s,s),T(Qs,s),T(Bs,s),T(Ss,s),T(zs,s),T(Rs,s),T(Ws,s),T(Vs,s),T(Xs,s),T(Ds,s),T(Ys,s),T(Fs,s),T(Os,s),T(Ks,s),T(nn,s),T(an,s),T(en,s)}}}const ct='{"title":"快速標記器的特殊能力","local":"快速標記器的特殊能力","sections":[{"title":"批量編碼","local":"批量編碼","sections":[],"depth":2},{"title":"在令牌分類管道內","local":"在令牌分類管道內","sections":[{"title":"通過管道獲得基本結果","local":"通過管道獲得基本結果","sections":[],"depth":3},{"title":"從輸入到預測","local":"從輸入到預測","sections":[],"depth":3},{"title":"分組實體","local":"分組實體","sections":[],"depth":3}],"depth":2}],"depth":1}';function jt(b,t,m){let e="pt";return Da(()=>{const o=new URLSearchParams(window.location.search);m(0,e=o.get("fw")||"pt")}),[e]}class ht extends Ya{constructor(t){super(),La(this,t,jt,it,Ga,{})}}export{ht as component};
