import{s as Ga,o as Da,n as Fl}from"../chunks/scheduler.37c15a92.js";import{S as Ya,i as La,g as w,s as p,r as c,A as Fa,h as u,f as l,c as r,j as Ha,u as j,x as o,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.4f5fc1ad.js";import{C as Xa}from"../chunks/CourseFloatingBanner.06521e8b.js";import{F as Pa}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as Tn,E as Oa}from"../chunks/EditOnGithub.8916dc7c.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,g){y(t,e,g),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,g){y(t,e,g),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=w("p"),t.textContent=m},l(e){t=u(e,"P",{"data-svelte-h":!0}),o(t)!=="svelte-ja6qya"&&(t.textContent=m)},m(e,g){a(e,t,g)},p:Fl,d(e){e&&l(t)}}}function lt(b){let t,m="一个词是什么的概念很复杂。例如，“I’ll”（“I will”的缩写）算一两个词吗？它实际上取决于分词器和它应用的预分词操作。一些标记器只是在空格上拆分，因此他们会将其视为一个词。其他人在空格顶部使用标点符号，因此将其视为两个词。",e,g,f="✏️ 试试看！从bert base cased和roberta base检查点创建一个标记器，并用它们标记“81s”。你观察到了什么？ID这个词是什么？";return{c(){t=w("p"),t.textContent=m,e=p(),g=w("p"),g.textContent=f},l(h){t=u(h,"P",{"data-svelte-h":!0}),o(t)!=="svelte-1e2odpb"&&(t.textContent=m),e=r(h),g=u(h,"P",{"data-svelte-h":!0}),o(g)!=="svelte-12hj0p2"&&(g.textContent=f)},m(h,k){a(h,t,k),a(h,e,k),a(h,g,k)},p:Fl,d(h){h&&(l(t),l(e),l(g))}}}function at(b){let t,m="✏️ 试试看！创建您自己的示例文本，看看您是否能理解哪些标记与单词 ID 相关联，以及如何提取单个单词的字符跨度。对于奖励积分，请尝试使用两个句子作为输入，看看句子 ID 是否对您有意义。";return{c(){t=w("p"),t.textContent=m},l(e){t=u(e,"P",{"data-svelte-h":!0}),o(t)!=="svelte-9p3d26"&&(t.textContent=m)},m(e,g){a(e,t,g)},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,g){y(t,e,g),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,g){y(t,e,g),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,g,f,h,k="于我们正在使用 <strong>AutoModelForTokenClassification</strong> 在这里，我们为输入序列中的每个标记获得一组 logits：",A,x,C,I,$;return g=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=w("p"),t.innerHTML=m,e=p(),c(g.$$.fragment),f=p(),h=w("p"),h.innerHTML=k,A=p(),c(x.$$.fragment),C=p(),c(I.$$.fragment)},l(M){t=u(M,"P",{"data-svelte-h":!0}),o(t)!=="svelte-176qejk"&&(t.innerHTML=m),e=r(M),j(g.$$.fragment,M),f=r(M),h=u(M,"P",{"data-svelte-h":!0}),o(h)!=="svelte-1t38vg9"&&(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(g,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(g.$$.fragment,M),i(x.$$.fragment,M),i(I.$$.fragment,M),$=!0)},o(M){J(g.$$.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(g,M),T(x,M),T(I,M)}}}function rt(b){let t,m='首先，我们需要标记我们的输入并将其传递给模型。这是完全按照<a href="/course/chapter2">Chapter 2</a>;我们使用 <strong>AutoXxx</strong> 类，然后在我们的示例中使用它们：',e,g,f,h,k="由于我们正在使用 <strong>AutoModelForTokenClassification</strong> 在这里，我们为输入序列中的每个标记获得一组 logits：",A,x,C,I,$;return g=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=w("p"),t.innerHTML=m,e=p(),c(g.$$.fragment),f=p(),h=w("p"),h.innerHTML=k,A=p(),c(x.$$.fragment),C=p(),c(I.$$.fragment)},l(M){t=u(M,"P",{"data-svelte-h":!0}),o(t)!=="svelte-176qejk"&&(t.innerHTML=m),e=r(M),j(g.$$.fragment,M),f=r(M),h=u(M,"P",{"data-svelte-h":!0}),o(h)!=="svelte-n990ok"&&(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(g,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(g.$$.fragment,M),i(x.$$.fragment,M),i(I.$$.fragment,M),$=!0)},o(M){J(g.$$.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(g,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,g){y(t,e,g),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,g){y(t,e,g),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,g,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,wn,V,ql='在接下来的讨论中，我们会经常区分“慢”和“快”分词器。慢速分词器是在 🤗 Transformers 库中用 Python 编写的，而快速版本是由 🤗 分词器提供的，它们是用 Rust 编写的。如果你还记得在<a href="/course/chapter5/3">Chapter 5</a>中报告了快速和慢速分词器对药物审查数据集进行分词所需的时间的这张表，您应该知道为什么我们称它们为“快”和“慢”：',un,H,Pl='<thead><tr><th align="center"></th> <th align="center">Fast tokenizer</th> <th align="center">Slow tokenizer</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>',gn,z,on,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,ws,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,us,Fn,gs,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,os,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,wa="<strong>model.config.id2label</strong> 属性包含索引到标签的映射，我们可以用它来理解预测：",Ml,Qs,Jl,Bs,il,Zs,ua="正如我们之前看到的，有 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,ga="在这种情况下，您可能认为模型是错误的，因为它给出了标签 <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,oa='<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,wl,_s,ha="这与我们之前的情况非常相似，只有一个例外：管道还为我们提供了有关 <strong>start</strong> 和 <strong>end</strong> 原始句子中的每个实体。这是我们的偏移映射将发挥作用的地方。要获得偏移量，我们只需要设置 <strong>return_offsets_mapping=True</strong> 当我们将分词器应用于我们的输入时：",ul,Rs,gl,Ws,ol,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),us=new Tn({props:{title:"通过管道获得基本结果",local:"通过管道获得基本结果",headingTag:"h3"}}),os=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:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5MzgyOCUyQyUyMCdpbmRleCclM0ElMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ1MnJTJDJTIwJ3N0YXJ0JyUzQSUyMDExJTJDJTIwJ2VuZCclM0ElMjAxMiU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5ODE1NDc2JTJDJTIwJ2luZGV4JyUzQSUyMDUlMkMlMjAnd29yZCclM0ElMjAnJTIzJTIzeWwnJTJDJTIwJ3N0YXJ0JyUzQSUyMDEyJTJDJTIwJ2VuZCclM0ElMjAxNCU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5NTkwNzI1JTJDJTIwJ2luZGV4JyUzQSUyMDYlMkMlMjAnd29yZCclM0ElMjAnJTIzJTIzdmEnJTJDJTIwJ3N0YXJ0JyUzQSUyMDE0JTJDJTIwJ2VuZCclM0ElMjAxNiU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEVSJyUyQyUyMCdzY29yZSclM0ElMjAwLjk5OTIzMjclMkMlMjAnaW5kZXgnJTNBJTIwNyUyQyUyMCd3b3JkJyUzQSUyMCclMjMlMjNpbiclMkMlMjAnc3RhcnQnJTNBJTIwMTYlMkMlMjAnZW5kJyUzQSUyMDE4JTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1PUkcnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTczODkzMzQlMkMlMjAnaW5kZXgnJTNBJTIwMTIlMkMlMjAnd29yZCclM0ElMjAnSHUnJTJDJTIwJ3N0YXJ0JyUzQSUyMDMzJTJDJTIwJ2VuZCclM0ElMjAzNSU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktT1JHJyUyQyUyMCdzY29yZSclM0ElMjAwLjk3NjExNSUyQyUyMCdpbmRleCclM0ElMjAxMyUyQyUyMCd3b3JkJyUzQSUyMCclMjMlMjNnZ2luZyclMkMlMjAnc3RhcnQnJTNBJTIwMzUlMkMlMjAnZW5kJyUzQSUyMDQwJTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1PUkcnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTg4Nzk3NjYlMkMlMjAnaW5kZXgnJTNBJTIwMTQlMkMlMjAnd29yZCclM0ElMjAnRmFjZSclMkMlMjAnc3RhcnQnJTNBJTIwNDElMkMlMjAnZW5kJyUzQSUyMDQ1JTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1MT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnaW5kZXgnJTNBJTIwMTYlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",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}}),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:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ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yMTA1NSUyQyUyMCdpbmRleCclM0ElMjAxNiUyQyUyMCd3b3JkJyUzQSUyMCdCcm9va2x5biclN0QlNUQ=",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:"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CUyMCUyMndvcmQlMjIlM0ElMjB0b2tlbnMlNUJpZHglNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUwQXByaW50KHJlc3VsdHMp",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:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5MzgyOCUyQyUyMCdpbmRleCclM0ElMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ1MnJTJDJTIwJ3N0YXJ0JyUzQSUyMDExJTJDJTIwJ2VuZCclM0ElMjAxMiU3RCUyQyUwQSUyMCU3Qidl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IwJ3Njb3JlJyUzQSUyMDAuOTg4Nzk3NjYlMkMlMjAnaW5kZXgnJTNBJTIwMTQlMkMlMjAnd29yZCclM0ElMjAnRmFjZSclMkMlMjAnc3RhcnQnJTNBJTIwNDElMkMlMjAnZW5kJyUzQSUyMDQ1JTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1MT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnaW5kZXgnJTNBJTIwMTYlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",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:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBcmVzdWx0cyUyMCUzRCUyMCU1QiU1RCUwQWlucHV0c193aXRoX29mZnNldHMlMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSUyQyUyMHJldHVybl9vZmZzZXRzX21hcHBpbmclM0RUcnVlKSUwQXRva2VucyUyMCUzRCUyMGlucHV0c193aXRoX29mZnNldHMudG9rZW5zKCklMEFvZmZzZXRzJTIwJTNEJTIwaW5wdXRzX3dpdGhfb2Zmc2V0cyU1QiUyMm9mZnNldF9tYXBwaW5nJTIyJTVEJ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wJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyd29yZCUyMiUzQSUyMHdvcmQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGlkeCUyMCUyQiUzRCUyMDElMEElMEFwcmludChyZXN1bHRzKQ==",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-CN/chapter6/3.mdx"}}),{c(){t=w("meta"),m=p(),e=w("p"),g=p(),c(f.$$.fragment),h=p(),c(k.$$.fragment),A=p(),C.c(),I=p(),$=w("p"),$.innerHTML=M,d=p(),c(v.$$.fragment),wn=p(),V=w("p"),V.innerHTML=ql,un=p(),H=w("table"),H.innerHTML=Pl,gn=p(),c(z.$$.fragment),on=p(),c(X.$$.fragment),Un=p(),c(G.$$.fragment),hn=p(),D=w("p"),D.innerHTML=Ol,xn=p(),Y=w("p"),Y.textContent=Kl,bn=p(),c(L.$$.fragment),dn=p(),F=w("p"),F.innerHTML=sa,In=p(),c(q.$$.fragment),fn=p(),P=w("p"),P.innerHTML=na,Cn=p(),c(O.$$.fragment),kn=p(),c(K.$$.fragment),$n=p(),ss=w("p"),ss.innerHTML=la,An=p(),c(ns.$$.fragment),Qn=p(),c(ls.$$.fragment),Bn=p(),as=w("p"),as.textContent=aa,Zn=p(),c(ts.$$.fragment),Nn=p(),c(es.$$.fragment),En=p(),ps=w("p"),ps.innerHTML=ta,Sn=p(),c(rs.$$.fragment),zn=p(),c(Ms.$$.fragment),_n=p(),Js=w("p"),Js.innerHTML=ea,Rn=p(),c(_.$$.fragment),Wn=p(),is=w("p"),is.innerHTML=pa,vn=p(),cs=w("p"),cs.innerHTML=ra,Vn=p(),c(js.$$.fragment),Hn=p(),c(ys.$$.fragment),Xn=p(),Ts=w("p"),Ts.innerHTML=Ma,Gn=p(),c(R.$$.fragment),Dn=p(),c(ms.$$.fragment),Yn=p(),ws=w("p"),ws.innerHTML=Ja,Ln=p(),B.c(),cn=p(),c(us.$$.fragment),Fn=p(),gs=w("p"),gs.innerHTML=ia,qn=p(),c(os.$$.fragment),Pn=p(),c(Us.$$.fragment),On=p(),hs=w("p"),hs.textContent=ca,Kn=p(),c(xs.$$.fragment),sl=p(),c(bs.$$.fragment),nl=p(),ds=w("p"),ds.innerHTML=ja,ll=p(),Is=w("ul"),Is.innerHTML=ya,al=p(),fs=w("p"),fs.textContent=Ta,tl=p(),c(Cs.$$.fragment),el=p(),N.c(),jn=p(),ks=w("p"),ks.textContent=ma,pl=p(),S.c(),yn=p(),c($s.$$.fragment),rl=p(),As=w("p"),As.innerHTML=wa,Ml=p(),c(Qs.$$.fragment),Jl=p(),c(Bs.$$.fragment),il=p(),Zs=w("p"),Zs.innerHTML=ua,cl=p(),Ns=w("p"),Ns.innerHTML=ga,jl=p(),W=w("div"),W.innerHTML=oa,yl=p(),Es=w("p"),Es.innerHTML=Ua,Tl=p(),c(Ss.$$.fragment),ml=p(),c(zs.$$.fragment),wl=p(),_s=w("p"),_s.innerHTML=ha,ul=p(),c(Rs.$$.fragment),gl=p(),c(Ws.$$.fragment),ol=p(),vs=w("p"),vs.innerHTML=xa,Ul=p(),c(Vs.$$.fragment),hl=p(),Hs=w("p"),Hs.innerHTML=ba,xl=p(),c(Xs.$$.fragment),bl=p(),Gs=w("p"),Gs.textContent=da,dl=p(),c(Ds.$$.fragment),Il=p(),c(Ys.$$.fragment),fl=p(),Ls=w("p"),Ls.textContent=Ia,Cl=p(),c(Fs.$$.fragment),kl=p(),qs=w("p"),qs.innerHTML=fa,$l=p(),Ps=w("p"),Ps.innerHTML=Ca,Al=p(),c(Os.$$.fragment),Ql=p(),c(Ks.$$.fragment),Bl=p(),sn=w("p"),sn.innerHTML=ka,Zl=p(),c(nn.$$.fragment),Nl=p(),ln=w("p"),ln.textContent=$a,El=p(),c(an.$$.fragment),Sl=p(),tn=w("p"),tn.textContent=Aa,zl=p(),c(en.$$.fragment),_l=p(),mn=w("p"),this.h()},l(s){const n=Fa("svelte-u9bgzb",document.head);t=u(n,"META",{name:!0,content:!0}),n.forEach(l),m=r(s),e=u(s,"P",{}),Ha(e).forEach(l),g=r(s),j(f.$$.fragment,s),h=r(s),j(k.$$.fragment,s),A=r(s),C.l(s),I=r(s),$=u(s,"P",{"data-svelte-h":!0}),o($)!=="svelte-7kigf1"&&($.innerHTML=M),d=r(s),j(v.$$.fragment,s),wn=r(s),V=u(s,"P",{"data-svelte-h":!0}),o(V)!=="svelte-116asck"&&(V.innerHTML=ql),un=r(s),H=u(s,"TABLE",{"data-svelte-h":!0}),o(H)!=="svelte-1tt5cf9"&&(H.innerHTML=Pl),gn=r(s),j(z.$$.fragment,s),on=r(s),j(X.$$.fragment,s),Un=r(s),j(G.$$.fragment,s),hn=r(s),D=u(s,"P",{"data-svelte-h":!0}),o(D)!=="svelte-vtkleu"&&(D.innerHTML=Ol),xn=r(s),Y=u(s,"P",{"data-svelte-h":!0}),o(Y)!=="svelte-1p4desp"&&(Y.textContent=Kl),bn=r(s),j(L.$$.fragment,s),dn=r(s),F=u(s,"P",{"data-svelte-h":!0}),o(F)!=="svelte-hllfac"&&(F.innerHTML=sa),In=r(s),j(q.$$.fragment,s),fn=r(s),P=u(s,"P",{"data-svelte-h":!0}),o(P)!=="svelte-1xppdmw"&&(P.innerHTML=na),Cn=r(s),j(O.$$.fragment,s),kn=r(s),j(K.$$.fragment,s),$n=r(s),ss=u(s,"P",{"data-svelte-h":!0}),o(ss)!=="svelte-1w5fp75"&&(ss.innerHTML=la),An=r(s),j(ns.$$.fragment,s),Qn=r(s),j(ls.$$.fragment,s),Bn=r(s),as=u(s,"P",{"data-svelte-h":!0}),o(as)!=="svelte-18yd79u"&&(as.textContent=aa),Zn=r(s),j(ts.$$.fragment,s),Nn=r(s),j(es.$$.fragment,s),En=r(s),ps=u(s,"P",{"data-svelte-h":!0}),o(ps)!=="svelte-17g0w73"&&(ps.innerHTML=ta),Sn=r(s),j(rs.$$.fragment,s),zn=r(s),j(Ms.$$.fragment,s),_n=r(s),Js=u(s,"P",{"data-svelte-h":!0}),o(Js)!=="svelte-khrde"&&(Js.innerHTML=ea),Rn=r(s),j(_.$$.fragment,s),Wn=r(s),is=u(s,"P",{"data-svelte-h":!0}),o(is)!=="svelte-69fbl5"&&(is.innerHTML=pa),vn=r(s),cs=u(s,"P",{"data-svelte-h":!0}),o(cs)!=="svelte-1vpg76q"&&(cs.innerHTML=ra),Vn=r(s),j(js.$$.fragment,s),Hn=r(s),j(ys.$$.fragment,s),Xn=r(s),Ts=u(s,"P",{"data-svelte-h":!0}),o(Ts)!=="svelte-kc0ven"&&(Ts.innerHTML=Ma),Gn=r(s),j(R.$$.fragment,s),Dn=r(s),j(ms.$$.fragment,s),Yn=r(s),ws=u(s,"P",{"data-svelte-h":!0}),o(ws)!=="svelte-1vxelrs"&&(ws.innerHTML=Ja),Ln=r(s),B.l(s),cn=r(s),j(us.$$.fragment,s),Fn=r(s),gs=u(s,"P",{"data-svelte-h":!0}),o(gs)!=="svelte-sc2mx9"&&(gs.innerHTML=ia),qn=r(s),j(os.$$.fragment,s),Pn=r(s),j(Us.$$.fragment,s),On=r(s),hs=u(s,"P",{"data-svelte-h":!0}),o(hs)!=="svelte-iqheyz"&&(hs.textContent=ca),Kn=r(s),j(xs.$$.fragment,s),sl=r(s),j(bs.$$.fragment,s),nl=r(s),ds=u(s,"P",{"data-svelte-h":!0}),o(ds)!=="svelte-12ikptf"&&(ds.innerHTML=ja),ll=r(s),Is=u(s,"UL",{"data-svelte-h":!0}),o(Is)!=="svelte-amqrbn"&&(Is.innerHTML=ya),al=r(s),fs=u(s,"P",{"data-svelte-h":!0}),o(fs)!=="svelte-e2giru"&&(fs.textContent=Ta),tl=r(s),j(Cs.$$.fragment,s),el=r(s),N.l(s),jn=r(s),ks=u(s,"P",{"data-svelte-h":!0}),o(ks)!=="svelte-1nefanp"&&(ks.textContent=ma),pl=r(s),S.l(s),yn=r(s),j($s.$$.fragment,s),rl=r(s),As=u(s,"P",{"data-svelte-h":!0}),o(As)!=="svelte-ftvm97"&&(As.innerHTML=wa),Ml=r(s),j(Qs.$$.fragment,s),Jl=r(s),j(Bs.$$.fragment,s),il=r(s),Zs=u(s,"P",{"data-svelte-h":!0}),o(Zs)!=="svelte-e56584"&&(Zs.innerHTML=ua),cl=r(s),Ns=u(s,"P",{"data-svelte-h":!0}),o(Ns)!=="svelte-1rtpizm"&&(Ns.innerHTML=ga),jl=r(s),W=u(s,"DIV",{class:!0,"data-svelte-h":!0}),o(W)!=="svelte-qf2tof"&&(W.innerHTML=oa),yl=r(s),Es=u(s,"P",{"data-svelte-h":!0}),o(Es)!=="svelte-1pq7pa5"&&(Es.innerHTML=Ua),Tl=r(s),j(Ss.$$.fragment,s),ml=r(s),j(zs.$$.fragment,s),wl=r(s),_s=u(s,"P",{"data-svelte-h":!0}),o(_s)!=="svelte-fvg2pj"&&(_s.innerHTML=ha),ul=r(s),j(Rs.$$.fragment,s),gl=r(s),j(Ws.$$.fragment,s),ol=r(s),vs=u(s,"P",{"data-svelte-h":!0}),o(vs)!=="svelte-1hxcqye"&&(vs.innerHTML=xa),Ul=r(s),j(Vs.$$.fragment,s),hl=r(s),Hs=u(s,"P",{"data-svelte-h":!0}),o(Hs)!=="svelte-1hqltgn"&&(Hs.innerHTML=ba),xl=r(s),j(Xs.$$.fragment,s),bl=r(s),Gs=u(s,"P",{"data-svelte-h":!0}),o(Gs)!=="svelte-44s1ne"&&(Gs.textContent=da),dl=r(s),j(Ds.$$.fragment,s),Il=r(s),j(Ys.$$.fragment,s),fl=r(s),Ls=u(s,"P",{"data-svelte-h":!0}),o(Ls)!=="svelte-1r4mkp0"&&(Ls.textContent=Ia),Cl=r(s),j(Fs.$$.fragment,s),kl=r(s),qs=u(s,"P",{"data-svelte-h":!0}),o(qs)!=="svelte-n7ksbe"&&(qs.innerHTML=fa),$l=r(s),Ps=u(s,"P",{"data-svelte-h":!0}),o(Ps)!=="svelte-1xh8kgc"&&(Ps.innerHTML=Ca),Al=r(s),j(Os.$$.fragment,s),Ql=r(s),j(Ks.$$.fragment,s),Bl=r(s),sn=u(s,"P",{"data-svelte-h":!0}),o(sn)!=="svelte-1xrcww8"&&(sn.innerHTML=ka),Zl=r(s),j(nn.$$.fragment,s),Nl=r(s),ln=u(s,"P",{"data-svelte-h":!0}),o(ln)!=="svelte-14g38x7"&&(ln.textContent=$a),El=r(s),j(an.$$.fragment,s),Sl=r(s),tn=u(s,"P",{"data-svelte-h":!0}),o(tn)!=="svelte-13ca8cf"&&(tn.textContent=Aa),zl=r(s),j(en.$$.fragment,s),_l=r(s),mn=u(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,g,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,wn,n),a(s,V,n),a(s,un,n),a(s,H,n),a(s,gn,n),y(z,s,n),a(s,on,n),y(X,s,n),a(s,Un,n),y(G,s,n),a(s,hn,n),a(s,D,n),a(s,xn,n),a(s,Y,n),a(s,bn,n),y(L,s,n),a(s,dn,n),a(s,F,n),a(s,In,n),y(q,s,n),a(s,fn,n),a(s,P,n),a(s,Cn,n),y(O,s,n),a(s,kn,n),y(K,s,n),a(s,$n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),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(us.$$.fragment,s),i(os.$$.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(us.$$.fragment,s),J(os.$$.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(g),l(h),l(A),l(I),l($),l(d),l(wn),l(V),l(un),l(H),l(gn),l(on),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(ws),l(Ln),l(cn),l(Fn),l(gs),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(wl),l(_s),l(ul),l(gl),l(ol),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(us,s),T(os,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 g=new URLSearchParams(window.location.search);m(0,e=g.get("fw")||"pt")}),[e]}class ht extends Ya{constructor(t){super(),La(this,t,jt,it,Ga,{})}}export{ht as component};
