import{s as Ha,o as Xa,n as Yl}from"../chunks/scheduler.37c15a92.js";import{S as Ga,i as Da,g as w,s as p,r as c,A as Ya,h as u,f as l,c as r,j as va,u as j,x as o,k as Gl,y as La,a,v as y,t as J,b as _l,d as i,w as T,p as Rl}from"../chunks/index.2bf4358c.js";import{T as Dl}from"../chunks/Tip.363c041f.js";import{Y as Wl}from"../chunks/Youtube.1e50a667.js";import{C as U}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Va}from"../chunks/CourseFloatingBanner.06521e8b.js";import{F as Fa}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as yn}from"../chunks/Heading.8ada512a.js";function qa(b){let t,m;return t=new Va({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 Pa(b){let t,m;return t=new Va({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 Oa(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:Yl,d(e){e&&l(t)}}}function Ka(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:Yl,d(h){h&&(l(t),l(e),l(g))}}}function st(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:Yl,d(e){e&&l(t)}}}function nt(b){let t,m;return t=new Wl({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 lt(b){let t,m;return t=new Wl({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 at(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 tt(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 et(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 pt(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 rt(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,mn,V,Ll='在接下来的讨论中，我们会经常区分“慢”和“快”分词器。慢速分词器是在 🤗 Transformers 库中用 Python 编写的，而快速版本是由 🤗 分词器提供的，它们是用 Rust 编写的。如果你还记得在<a href="/course/chapter5/3">Chapter 5</a>中报告了快速和慢速分词器对药物审查数据集进行分词所需的时间的这张表，您应该知道为什么我们称它们为“快”和“慢”：',wn,H,Fl='<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>',un,z,gn,X,on,G,Un,D,ql="分词器的输出不是简单的 Python 字典；我们得到的实际上是一个特殊的 <strong>BatchEncoding</strong> 目的。它是字典的子类（这就是为什么我们之前能够毫无问题地索引到该结果中的原因），但具有主要由快速标记器使用的附加方法。",hn,Y,Pl="除了它们的并行化能力之外，快速标记器的关键功能是它们始终跟踪最终标记来自的原始文本范围——我们称之为偏移映射.这反过来又解锁了诸如将每个单词映射到它生成的标记或将原始文本的每个字符映射到它内部的标记等功能，反之亦然。让我们看一个例子：",xn,L,bn,F,Ol="如前所述，我们得到一个 <strong>BatchEncoding</strong> 标记器输出中的对象：",dn,q,In,P,Kl="由于 <strong>AutoTokenizer</strong> 类默认选择快速标记器，我们可以使用附加方法 this <strong>BatchEncoding</strong> 对象提供。我们有两种方法来检查我们的分词器是快的还是慢的。我们可以检查 <strong>is_fast</strong> 的属性 <strong>tokenizer</strong> ：",fn,O,Cn,K,kn,ss,sa="或检查我们的相同属性 <strong>encoding</strong> ：",$n,ns,An,ls,Qn,as,na="让我们看看快速标记器使我们能够做什么。首先，我们可以访问令牌而无需将 ID 转换回令牌：",Bn,ts,Zn,es,Nn,ps,la="在这种情况下，索引 5 处的令牌是 <strong>##yl</strong> ，它是原始句子中“Sylvain”一词的一部分。我们也可以使用 <strong>word_ids()</strong> 获取每个标记来自的单词索引的方法：",En,rs,Sn,Ms,zn,Js,aa="我们可以看到分词器的特殊标记 <strong>[CLS]</strong> 和 <strong>[SEP]</strong> 被映射到 <strong>None</strong> ，然后每个标记都映射到它起源的单词。这对于确定一个标记是否在单词的开头或两个标记是否在同一个单词中特别有用。我们可以依靠 <strong>##</strong> 前缀，但它仅适用于类似 BERT 的分词器；这种方法适用于任何类型的标记器，只要它是快速的。在下一章中，我们将看到如何使用此功能将每个单词的标签正确应用于命名实体识别 (NER) 和词性 (POS) 标记等任务中的标记。我们还可以使用它来屏蔽来自屏蔽语言建模中来自同一单词的所有标记（一种称为全词掩码）。",_n,_,Rn,is,ta="同样，有一个 <strong>sentence_ids()</strong> 我们可以用来将标记映射到它来自的句子的方法（尽管在这种情况下， <strong>token_type_ids</strong> 分词器返回的信息可以为我们提供相同的信息）。",Wn,cs,ea="最后，我们可以将任何单词或标记映射到原始文本中的字符，反之亦然，通过 <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,Vn,ys,Hn,Ts,pa="正如我们之前提到的，这一切都是由快速标记器跟踪每个标记来自列表中的文本跨度这一事实提供支持的抵消.为了说明它们的用途，接下来我们将向您展示如何复制结果 <strong>token-classification</strong> 手动管道。",Xn,R,Gn,ms,Dn,ws,ra='在<a href="/course/chapter1">Chapter 1</a>我们第一次尝试使用 NER——任务是识别文本的哪些部分对应于个人、地点或组织等实体——使用 🤗 Transformers <strong>pipeline()</strong> 功能。然后，在<a href="/course/chapter2">Chapter 2</a>，我们看到了管道如何将从原始文本中获取预测所需的三个阶段组合在一起：标记化、通过模型传递输入和后处理。前两步 <strong>token-classification</strong> 管道与任何其他管道相同，但后处理稍微复杂一些 - 让我们看看如何！',Yn,Q,B,Jn,us,Ln,gs,Ma='首先，让我们获取一个标记分类管道，以便我们可以手动比较一些结果。默认使用的模型是<a href="https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english" rel="nofollow">dbmdz/bert-large-cased-finetuned-conll03-english</a>;它对句子执行 NER：',Fn,os,qn,Us,Pn,hs,Ja="该模型正确地将“Sylvain”生成的每个标记识别为一个人，将“Hugging Face”生成的每个标记识别为一个组织，将“Brooklyn”生成的标记识别为一个位置。我们还可以要求管道将对应于同一实体的令牌组合在一起：",On,xs,Kn,bs,sl,ds,ia="<strong>aggregation_strategy</strong> 选择将更改为每个分组实体计算的分数。和 <strong>simple</strong> 分数只是给定实体中每个标记的分数的平均值：例如，“Sylvain”的分数是我们在前面的示例中看到的标记分数的平均值 <strong>S</strong> , <strong>##yl</strong> , <strong>##va</strong> ， 和 <strong>##in</strong> .其他可用的策略是：",nl,Is,ca="<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>",ll,fs,ja="现在让我们看看如何在不使用pipeline（）函数的情况下获得这些结果！",al,Cs,tl,Z,N,cn,ks,ya="我们有一个包含 19 个标记的 1 个序列的批次，模型有 9 个不同的标签，因此模型的输出具有 1 x 19 x 9 的形状。与文本分类管道一样，我们使用 softmax 函数来转换这些 logits到概率，我们采用 argmax 来获得预测（请注意，我们可以在 logits 上采用 argmax，因为 softmax 不会改变顺序）：",el,E,S,jn,$s,pl,As,Ta="<strong>model.config.id2label</strong> 属性包含索引到标签的映射，我们可以用它来理解预测：",rl,Qs,Ml,Bs,Jl,Zs,ma="正如我们之前看到的，有 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> （在个人实体内）",il,Ns,wa="在这种情况下，您可能认为模型是错误的，因为它给出了标签 <strong>I-PER</strong> 对所有这四个令牌，但这并不完全正确。实际上有两种格式 <strong>B-</strong> 和 <strong>I-</strong> 标签：IOB1和IOB2. IOB2 格式（下面粉红色）是我们介绍的格式，而在 IOB1 格式（蓝色）中，标签以 <strong>B-</strong> 仅用于分隔相同类型的两个相邻实体。我们使用的模型在使用该格式的数据集上进行了微调，这就是它分配标签的原因 <strong>I-PER</strong> 到 <strong>S</strong> 令牌。",cl,W,ua='<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"/>',jl,Es,ga="了这张地图，我们已经准备好（几乎完全）重现第一个管道的结果——我们可以获取每个未被归类为的标记的分数和标签 <strong>O</strong> ：",yl,Ss,Tl,zs,ml,_s,oa="这与我们之前的情况非常相似，只有一个例外：管道还为我们提供了有关 <strong>start</strong> 和 <strong>end</strong> 原始句子中的每个实体。这是我们的偏移映射将发挥作用的地方。要获得偏移量，我们只需要设置 <strong>return_offsets_mapping=True</strong> 当我们将分词器应用于我们的输入时：",wl,Rs,ul,Ws,gl,vs,Ua="每个元组是对应于每个标记的文本跨度，其中 <strong>(0, 0)</strong> 保留用于特殊令牌。我们之前看到索引 5 处的令牌是 <strong>##yl</strong> ， 其中有 <strong>(12, 14)</strong> 作为这里的抵消。如果我们在示例中抓取相应的切片：",ol,Vs,Ul,Hs,ha="我们得到了正确的文本跨度，而没有 <strong>##</strong> ：",hl,Xs,xl,Gs,xa="使用这个，我们现在可以完成之前的结果：",bl,Ds,dl,Ys,Il,Ls,ba="这和我们从第一个管道中得到的一样！",fl,Fs,Cl,qs,da="使用偏移量来确定每个实体的开始和结束键很方便，但该信息并不是绝对必要的。然而，当我们想要将实体组合在一起时，偏移量将为我们节省大量混乱的代码。例如，如果我们想将令牌组合在一起 <strong>Hu</strong> , <strong>##gging</strong> ， 和 <strong>Face</strong> ，我们可以制定特殊的规则，说前两个应该附加，同时删除 <strong>##</strong> ，以及 <strong>Face</strong> 应该添加一个空格，因为它不以 <strong>##</strong> — 但这仅适用于这种特定类型的标记器。我们必须为 SentencePiece 或 Byte-Pair-Encoding 分词器（本章稍后讨论）。",kl,Ps,Ia="编写另一组规则。使用偏移量，所有自定义代码都消失了：我们可以在原始文本中获取从第一个标记开始到最后一个标记结束的跨度。所以，在令牌的情况下 <strong>Hu</strong> , <strong>##gging</strong> ， 和 <strong>Face</strong> ，我们应该从字符 33（开始 <strong>Hu</strong> ) 并在字符 45 之前结束（结束 <strong>Face</strong> )：",$l,Os,Al,Ks,Ql,sn,fa="为了编写在对实体进行分组的同时对预测进行后处理的代码，我们将连续并标记为的实体分组在一起 <strong>I-XXX</strong> ，除了第一个，可以标记为 <strong>B-XXX</strong> 或者 <strong>I-XXX</strong> （因此，当我们得到一个实体时，我们停止对实体进行分组 <strong>O</strong> ，一种新型实体，或 <strong>B-XXX</strong> 这告诉我们一个相同类型的实体正在启动）：",Bl,nn,Zl,ln,Ca="我们得到了与第二条管道相同的结果！",Nl,an,El,tn,ka="这些偏移量非常有用的另一个任务示例是问答。深入研究这个管道，我们将在下一节中进行，也将使我们能够了解 🤗 Transformers 库中标记器的最后一个功能：当我们将输入截断为给定长度时处理溢出的标记。",Sl,Tn,zl;f=new Fa({props:{fw:b[0]}}),k=new yn({props:{title:"快速标记器的特殊能力",local:"快速标记器的特殊能力",headingTag:"h1"}});const $a=[Pa,qa],en=[];function Aa(s,n){return s[0]==="pt"?0:1}x=Aa(b),C=en[x]=$a[x](b),v=new Wl({props:{id:"g8quOxoqhHQ"}}),z=new Dl({props:{warning:!0,$$slots:{default:[Oa]},$$scope:{ctx:b}}}),X=new yn({props:{title:"批量编码",local:"批量编码",headingTag:"h2"}}),G=new Wl({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 Dl({props:{$$slots:{default:[Ka]},$$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 Dl({props:{$$slots:{default:[st]},$$scope:{ctx:b}}}),ms=new yn({props:{title:"在令牌分类管道内",local:"在令牌分类管道内",headingTag:"h2"}});const Qa=[lt,nt],pn=[];function Ba(s,n){return s[0]==="pt"?0:1}Q=Ba(b),B=pn[Q]=Qa[Q](b),us=new yn({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 yn({props:{title:"从输入到预测",local:"从输入到预测",headingTag:"h3"}});const Za=[tt,at],rn=[];function Na(s,n){return s[0]==="pt"?0:1}Z=Na(b),N=rn[Z]=Za[Z](b);const Ea=[pt,et],Mn=[];function Sa(s,n){return s[0]==="pt"?0:1}return E=Sa(b),S=Mn[E]=Ea[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:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk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M0ElMjAxNiUyQyUyMCd3b3JkJyUzQSUyMCdCcm9va2x5biclN0QlNUQ=",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}}),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jB0b2tlbnMlNUJpZHglNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUwQXByaW50KHJlc3VsdHMp",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:"JTVCJTdCJ2VudGl0eSclM0ElMjAnSS1QRVInJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTk5MzgyOCUyQyUyMCdpbmRleCclM0ElMjA0JTJDJTIwJ3dvcmQnJTNBJTIwJ1MnJTJDJTIwJ3N0YXJ0JyUzQSUyMDExJTJDJTIwJ2VuZCclM0ElMjAxMiU3RCUyQyUwQSUyMCU3QidlbnRpdHknJTNBJTIwJ0ktUEV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OTg4Nzk3NjYlMkMlMjAnaW5kZXgnJTNBJTIwMTQlMkMlMjAnd29yZCclM0ElMjAnRmFjZSclMkMlMjAnc3RhcnQnJTNBJTIwNDElMkMlMjAnZW5kJyUzQSUyMDQ1JTdEJTJDJTBBJTIwJTdCJ2VudGl0eSclM0ElMjAnSS1MT0MnJTJDJTIwJ3Njb3JlJyUzQSUyMDAuOTkzMjEwNTUlMkMlMjAnaW5kZXgnJTNBJTIwMTYlMkMlMjAnd29yZCclM0ElMjAnQnJvb2tseW4nJTJDJTIwJ3N0YXJ0JyUzQSUyMDQ5JTJDJTIwJ2VuZCclM0ElMjA1NyU3RCU1RA==",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 yn({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:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBcmVzdWx0cyUyMCUzRCUyMCU1QiU1RCUwQWlucHV0c193aXRoX29mZnNldHMlMjAlM0QlMjB0b2tlbml6ZXIoZXhhbXBsZSUyQyUyMHJldHVybl9vZmZzZXRzX21hcHBpbmclM0RUcnVlKSUwQXRva2VucyUyMCUzRCUyMGlucHV0c193aXRoX29mZnNldHMudG9rZW5zKCklMEFvZmZzZXRzJTIwJTNEJTIwaW5wdXRzX3dpdGhfb2Zmc2V0cyU1QiUyMm9mZnNldF9tYXBwaW5nJTIyJTVEJTBBJTBBaWR4JTIwJTNEJTIwM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wJTIwJTIwJTIyd29yZCUyMiUzQSUyMHdvcmQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdEJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKSUwQSUyMCUyMCUyMCUyMGlkeCUyMCUyQiUzRCUyMDElMEElMEFwcmludChyZXN1bHRzKQ==",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}}),{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),mn=p(),V=w("p"),V.innerHTML=Ll,wn=p(),H=w("table"),H.innerHTML=Fl,un=p(),c(z.$$.fragment),gn=p(),c(X.$$.fragment),on=p(),c(G.$$.fragment),Un=p(),D=w("p"),D.innerHTML=ql,hn=p(),Y=w("p"),Y.textContent=Pl,xn=p(),c(L.$$.fragment),bn=p(),F=w("p"),F.innerHTML=Ol,dn=p(),c(q.$$.fragment),In=p(),P=w("p"),P.innerHTML=Kl,fn=p(),c(O.$$.fragment),Cn=p(),c(K.$$.fragment),kn=p(),ss=w("p"),ss.innerHTML=sa,$n=p(),c(ns.$$.fragment),An=p(),c(ls.$$.fragment),Qn=p(),as=w("p"),as.textContent=na,Bn=p(),c(ts.$$.fragment),Zn=p(),c(es.$$.fragment),Nn=p(),ps=w("p"),ps.innerHTML=la,En=p(),c(rs.$$.fragment),Sn=p(),c(Ms.$$.fragment),zn=p(),Js=w("p"),Js.innerHTML=aa,_n=p(),c(_.$$.fragment),Rn=p(),is=w("p"),is.innerHTML=ta,Wn=p(),cs=w("p"),cs.innerHTML=ea,vn=p(),c(js.$$.fragment),Vn=p(),c(ys.$$.fragment),Hn=p(),Ts=w("p"),Ts.innerHTML=pa,Xn=p(),c(R.$$.fragment),Gn=p(),c(ms.$$.fragment),Dn=p(),ws=w("p"),ws.innerHTML=ra,Yn=p(),B.c(),Jn=p(),c(us.$$.fragment),Ln=p(),gs=w("p"),gs.innerHTML=Ma,Fn=p(),c(os.$$.fragment),qn=p(),c(Us.$$.fragment),Pn=p(),hs=w("p"),hs.textContent=Ja,On=p(),c(xs.$$.fragment),Kn=p(),c(bs.$$.fragment),sl=p(),ds=w("p"),ds.innerHTML=ia,nl=p(),Is=w("ul"),Is.innerHTML=ca,ll=p(),fs=w("p"),fs.textContent=ja,al=p(),c(Cs.$$.fragment),tl=p(),N.c(),cn=p(),ks=w("p"),ks.textContent=ya,el=p(),S.c(),jn=p(),c($s.$$.fragment),pl=p(),As=w("p"),As.innerHTML=Ta,rl=p(),c(Qs.$$.fragment),Ml=p(),c(Bs.$$.fragment),Jl=p(),Zs=w("p"),Zs.innerHTML=ma,il=p(),Ns=w("p"),Ns.innerHTML=wa,cl=p(),W=w("div"),W.innerHTML=ua,jl=p(),Es=w("p"),Es.innerHTML=ga,yl=p(),c(Ss.$$.fragment),Tl=p(),c(zs.$$.fragment),ml=p(),_s=w("p"),_s.innerHTML=oa,wl=p(),c(Rs.$$.fragment),ul=p(),c(Ws.$$.fragment),gl=p(),vs=w("p"),vs.innerHTML=Ua,ol=p(),c(Vs.$$.fragment),Ul=p(),Hs=w("p"),Hs.innerHTML=ha,hl=p(),c(Xs.$$.fragment),xl=p(),Gs=w("p"),Gs.textContent=xa,bl=p(),c(Ds.$$.fragment),dl=p(),c(Ys.$$.fragment),Il=p(),Ls=w("p"),Ls.textContent=ba,fl=p(),c(Fs.$$.fragment),Cl=p(),qs=w("p"),qs.innerHTML=da,kl=p(),Ps=w("p"),Ps.innerHTML=Ia,$l=p(),c(Os.$$.fragment),Al=p(),c(Ks.$$.fragment),Ql=p(),sn=w("p"),sn.innerHTML=fa,Bl=p(),c(nn.$$.fragment),Zl=p(),ln=w("p"),ln.textContent=Ca,Nl=p(),c(an.$$.fragment),El=p(),tn=w("p"),tn.textContent=ka,Sl=p(),Tn=w("p"),this.h()},l(s){const n=Ya("svelte-u9bgzb",document.head);t=u(n,"META",{name:!0,content:!0}),n.forEach(l),m=r(s),e=u(s,"P",{}),va(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),mn=r(s),V=u(s,"P",{"data-svelte-h":!0}),o(V)!=="svelte-116asck"&&(V.innerHTML=Ll),wn=r(s),H=u(s,"TABLE",{"data-svelte-h":!0}),o(H)!=="svelte-1tt5cf9"&&(H.innerHTML=Fl),un=r(s),j(z.$$.fragment,s),gn=r(s),j(X.$$.fragment,s),on=r(s),j(G.$$.fragment,s),Un=r(s),D=u(s,"P",{"data-svelte-h":!0}),o(D)!=="svelte-vtkleu"&&(D.innerHTML=ql),hn=r(s),Y=u(s,"P",{"data-svelte-h":!0}),o(Y)!=="svelte-1p4desp"&&(Y.textContent=Pl),xn=r(s),j(L.$$.fragment,s),bn=r(s),F=u(s,"P",{"data-svelte-h":!0}),o(F)!=="svelte-hllfac"&&(F.innerHTML=Ol),dn=r(s),j(q.$$.fragment,s),In=r(s),P=u(s,"P",{"data-svelte-h":!0}),o(P)!=="svelte-1xppdmw"&&(P.innerHTML=Kl),fn=r(s),j(O.$$.fragment,s),Cn=r(s),j(K.$$.fragment,s),kn=r(s),ss=u(s,"P",{"data-svelte-h":!0}),o(ss)!=="svelte-1w5fp75"&&(ss.innerHTML=sa),$n=r(s),j(ns.$$.fragment,s),An=r(s),j(ls.$$.fragment,s),Qn=r(s),as=u(s,"P",{"data-svelte-h":!0}),o(as)!=="svelte-18yd79u"&&(as.textContent=na),Bn=r(s),j(ts.$$.fragment,s),Zn=r(s),j(es.$$.fragment,s),Nn=r(s),ps=u(s,"P",{"data-svelte-h":!0}),o(ps)!=="svelte-17g0w73"&&(ps.innerHTML=la),En=r(s),j(rs.$$.fragment,s),Sn=r(s),j(Ms.$$.fragment,s),zn=r(s),Js=u(s,"P",{"data-svelte-h":!0}),o(Js)!=="svelte-khrde"&&(Js.innerHTML=aa),_n=r(s),j(_.$$.fragment,s),Rn=r(s),is=u(s,"P",{"data-svelte-h":!0}),o(is)!=="svelte-69fbl5"&&(is.innerHTML=ta),Wn=r(s),cs=u(s,"P",{"data-svelte-h":!0}),o(cs)!=="svelte-1vpg76q"&&(cs.innerHTML=ea),vn=r(s),j(js.$$.fragment,s),Vn=r(s),j(ys.$$.fragment,s),Hn=r(s),Ts=u(s,"P",{"data-svelte-h":!0}),o(Ts)!=="svelte-kc0ven"&&(Ts.innerHTML=pa),Xn=r(s),j(R.$$.fragment,s),Gn=r(s),j(ms.$$.fragment,s),Dn=r(s),ws=u(s,"P",{"data-svelte-h":!0}),o(ws)!=="svelte-1vxelrs"&&(ws.innerHTML=ra),Yn=r(s),B.l(s),Jn=r(s),j(us.$$.fragment,s),Ln=r(s),gs=u(s,"P",{"data-svelte-h":!0}),o(gs)!=="svelte-sc2mx9"&&(gs.innerHTML=Ma),Fn=r(s),j(os.$$.fragment,s),qn=r(s),j(Us.$$.fragment,s),Pn=r(s),hs=u(s,"P",{"data-svelte-h":!0}),o(hs)!=="svelte-iqheyz"&&(hs.textContent=Ja),On=r(s),j(xs.$$.fragment,s),Kn=r(s),j(bs.$$.fragment,s),sl=r(s),ds=u(s,"P",{"data-svelte-h":!0}),o(ds)!=="svelte-12ikptf"&&(ds.innerHTML=ia),nl=r(s),Is=u(s,"UL",{"data-svelte-h":!0}),o(Is)!=="svelte-amqrbn"&&(Is.innerHTML=ca),ll=r(s),fs=u(s,"P",{"data-svelte-h":!0}),o(fs)!=="svelte-e2giru"&&(fs.textContent=ja),al=r(s),j(Cs.$$.fragment,s),tl=r(s),N.l(s),cn=r(s),ks=u(s,"P",{"data-svelte-h":!0}),o(ks)!=="svelte-1nefanp"&&(ks.textContent=ya),el=r(s),S.l(s),jn=r(s),j($s.$$.fragment,s),pl=r(s),As=u(s,"P",{"data-svelte-h":!0}),o(As)!=="svelte-ftvm97"&&(As.innerHTML=Ta),rl=r(s),j(Qs.$$.fragment,s),Ml=r(s),j(Bs.$$.fragment,s),Jl=r(s),Zs=u(s,"P",{"data-svelte-h":!0}),o(Zs)!=="svelte-e56584"&&(Zs.innerHTML=ma),il=r(s),Ns=u(s,"P",{"data-svelte-h":!0}),o(Ns)!=="svelte-1rtpizm"&&(Ns.innerHTML=wa),cl=r(s),W=u(s,"DIV",{class:!0,"data-svelte-h":!0}),o(W)!=="svelte-qf2tof"&&(W.innerHTML=ua),jl=r(s),Es=u(s,"P",{"data-svelte-h":!0}),o(Es)!=="svelte-1pq7pa5"&&(Es.innerHTML=ga),yl=r(s),j(Ss.$$.fragment,s),Tl=r(s),j(zs.$$.fragment,s),ml=r(s),_s=u(s,"P",{"data-svelte-h":!0}),o(_s)!=="svelte-fvg2pj"&&(_s.innerHTML=oa),wl=r(s),j(Rs.$$.fragment,s),ul=r(s),j(Ws.$$.fragment,s),gl=r(s),vs=u(s,"P",{"data-svelte-h":!0}),o(vs)!=="svelte-1hxcqye"&&(vs.innerHTML=Ua),ol=r(s),j(Vs.$$.fragment,s),Ul=r(s),Hs=u(s,"P",{"data-svelte-h":!0}),o(Hs)!=="svelte-1hqltgn"&&(Hs.innerHTML=ha),hl=r(s),j(Xs.$$.fragment,s),xl=r(s),Gs=u(s,"P",{"data-svelte-h":!0}),o(Gs)!=="svelte-44s1ne"&&(Gs.textContent=xa),bl=r(s),j(Ds.$$.fragment,s),dl=r(s),j(Ys.$$.fragment,s),Il=r(s),Ls=u(s,"P",{"data-svelte-h":!0}),o(Ls)!=="svelte-1r4mkp0"&&(Ls.textContent=ba),fl=r(s),j(Fs.$$.fragment,s),Cl=r(s),qs=u(s,"P",{"data-svelte-h":!0}),o(qs)!=="svelte-n7ksbe"&&(qs.innerHTML=da),kl=r(s),Ps=u(s,"P",{"data-svelte-h":!0}),o(Ps)!=="svelte-1xh8kgc"&&(Ps.innerHTML=Ia),$l=r(s),j(Os.$$.fragment,s),Al=r(s),j(Ks.$$.fragment,s),Ql=r(s),sn=u(s,"P",{"data-svelte-h":!0}),o(sn)!=="svelte-1xrcww8"&&(sn.innerHTML=fa),Bl=r(s),j(nn.$$.fragment,s),Zl=r(s),ln=u(s,"P",{"data-svelte-h":!0}),o(ln)!=="svelte-14g38x7"&&(ln.textContent=Ca),Nl=r(s),j(an.$$.fragment,s),El=r(s),tn=u(s,"P",{"data-svelte-h":!0}),o(tn)!=="svelte-13ca8cf"&&(tn.textContent=ka),Sl=r(s),Tn=u(s,"P",{}),va(Tn).forEach(l),this.h()},h(){Gl(t,"name","hf:doc:metadata"),Gl(t,"content",Mt),Gl(W,"class","flex justify-center")},m(s,n){La(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),en[x].m(s,n),a(s,I,n),a(s,$,n),a(s,d,n),y(v,s,n),a(s,mn,n),a(s,V,n),a(s,wn,n),a(s,H,n),a(s,un,n),y(z,s,n),a(s,gn,n),y(X,s,n),a(s,on,n),y(G,s,n),a(s,Un,n),a(s,D,n),a(s,hn,n),a(s,Y,n),a(s,xn,n),y(L,s,n),a(s,bn,n),a(s,F,n),a(s,dn,n),y(q,s,n),a(s,In,n),a(s,P,n),a(s,fn,n),y(O,s,n),a(s,Cn,n),y(K,s,n),a(s,kn,n),a(s,ss,n),a(s,$n,n),y(ns,s,n),a(s,An,n),y(ls,s,n),a(s,Qn,n),a(s,as,n),a(s,Bn,n),y(ts,s,n),a(s,Zn,n),y(es,s,n),a(s,Nn,n),a(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y(nn,s,n),a(s,Zl,n),a(s,ln,n),a(s,Nl,n),y(an,s,n),a(s,El,n),a(s,tn,n),a(s,Sl,n),a(s,Tn,n),zl=!0},p(s,[n]){const za={};n&1&&(za.fw=s[0]),f.$set(za);let vl=x;x=Aa(s),x!==vl&&(Rl(),J(en[vl],1,1,()=>{en[vl]=null}),_l(),C=en[x],C||(C=en[x]=$a[x](s),C.c()),i(C,1),C.m(I.parentNode,I));const _a={};n&2&&(_a.$$scope={dirty:n,ctx:s}),z.$set(_a);const Ra={};n&2&&(Ra.$$scope={dirty:n,ctx:s}),_.$set(Ra);const Wa={};n&2&&(Wa.$$scope={dirty:n,ctx:s}),R.$set(Wa);let Vl=Q;Q=Ba(s),Q!==Vl&&(Rl(),J(pn[Vl],1,1,()=>{pn[Vl]=null}),_l(),B=pn[Q],B||(B=pn[Q]=Qa[Q](s),B.c()),i(B,1),B.m(Jn.parentNode,Jn));let Hl=Z;Z=Na(s),Z!==Hl&&(Rl(),J(rn[Hl],1,1,()=>{rn[Hl]=null}),_l(),N=rn[Z],N||(N=rn[Z]=Za[Z](s),N.c()),i(N,1),N.m(cn.parentNode,cn));let Xl=E;E=Sa(s),E!==Xl&&(Rl(),J(Mn[Xl],1,1,()=>{Mn[Xl]=null}),_l(),S=Mn[E],S||(S=Mn[E]=Ea[E](s),S.c()),i(S,1),S.m(jn.parentNode,jn))},i(s){zl||(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),zl=!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),zl=!1},d(s){s&&(l(m),l(e),l(g),l(h),l(A),l(I),l($),l(d),l(mn),l(V),l(wn),l(H),l(un),l(gn),l(on),l(Un),l(D),l(hn),l(Y),l(xn),l(bn),l(F),l(dn),l(In),l(P),l(fn),l(Cn),l(kn),l(ss),l($n),l(An),l(Qn),l(as),l(Bn),l(Zn),l(Nn),l(ps),l(En),l(Sn),l(zn),l(Js),l(_n),l(Rn),l(is),l(Wn),l(cs),l(vn),l(Vn),l(Hn),l(Ts),l(Xn),l(Gn),l(Dn),l(ws),l(Yn),l(Jn),l(Ln),l(gs),l(Fn),l(qn),l(Pn),l(hs),l(On),l(Kn),l(sl),l(ds),l(nl),l(Is),l(ll),l(fs),l(al),l(tl),l(cn),l(ks),l(el),l(jn),l(pl),l(As),l(rl),l(Ml),l(Jl),l(Zs),l(il),l(Ns),l(cl),l(W),l(jl),l(Es),l(yl),l(Tl),l(ml),l(_s),l(wl),l(ul),l(gl),l(vs),l(ol),l(Ul),l(Hs),l(hl),l(xl),l(Gs),l(bl),l(dl),l(Il),l(Ls),l(fl),l(Cl),l(qs),l(kl),l(Ps),l($l),l(Al),l(Ql),l(sn),l(Bl),l(Zl),l(ln),l(Nl),l(El),l(tn),l(Sl),l(Tn)),l(t),T(f,s),T(k,s),en[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),pn[Q].d(s),T(us,s),T(os,s),T(Us,s),T(xs,s),T(bs,s),T(Cs,s),rn[Z].d(s),Mn[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)}}}const Mt='{"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 Xa(()=>{const g=new URLSearchParams(window.location.search);m(0,e=g.get("fw")||"pt")}),[e]}class gt extends Ga{constructor(t){super(),Da(this,t,Jt,rt,Ha,{})}}export{gt as component};
