import{s as ge,o as _e,n as wt}from"../chunks/scheduler.37c15a92.js";import{S as $e,i as ke,g as u,s as r,r as J,A as Ce,h as j,f as n,c as M,j as fe,u as U,x as m,k as he,y as xe,a,v as b,t as y,b as Ls,d as o,w as T,p as Ps}from"../chunks/index.2bf4358c.js";import{T as dt}from"../chunks/Tip.363c041f.js";import{Y as rl}from"../chunks/Youtube.1e50a667.js";import{C as w}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as we}from"../chunks/CourseFloatingBanner.06521e8b.js";import{F as Ie}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as mt}from"../chunks/Heading.8ada512a.js";function Re(f){let t,p;return t=new we({props:{chapter:3,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/chapter3/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter3/section2_tf.ipynb"}]}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Ze(f){let t,p;return t=new we({props:{chapter:3,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/chapter3/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/zh-CN/chapter3/section2_pt.ipynb"}]}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Ne(f){let t,p='这一小节学习<a href="/course/chapter2">第一小节</a>中提到的“如何使用模型中心（hub）大型数据集”，下面是我们用模型中心的数据在TensorFlow上训练句子分类器的一个例子：',e,i,d;return i=new w({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b1Rva2VuaXplciUyQyUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQSUyMyUyMFNhbWUlMjBhcyUyMGJlZm9yZSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBc2VxdWVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIySSd2ZSUyMGJlZW4lMjB3YWl0aW5nJTIwZm9yJTIwYSUyMEh1Z2dpbmdGYWNlJTIwY291cnNlJTIwbXklMjB3aG9sZSUyMGxpZmUuJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIyVGhpcyUyMGNvdXJzZSUyMGlzJTIwYW1hemluZyElMjIlMkMlMEElNUQlMEFiYXRjaCUyMCUzRCUyMGRpY3QodG9rZW5pemVyKHNlcXVlbmNlcyUyQyUyMHBhZGRpbmclM0RUcnVlJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKSklMEElMEElMjMlMjBUaGlzJTIwaXMlMjBuZXclMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRCUyMmFkYW0lMjIlMkMlMjBsb3NzJTNEJTIyc3BhcnNlX2NhdGVnb3JpY2FsX2Nyb3NzZW50cm9weSUyMiklMEFsYWJlbHMlMjAlM0QlMjB0Zi5jb252ZXJ0X3RvX3RlbnNvciglNUIxJTJDJTIwMSU1RCklMEFtb2RlbC50cmFpbl9vbl9iYXRjaChiYXRjaCUyQyUyMGxhYmVscyk=",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

<span class="hljs-comment"># Same as before</span>
checkpoint = <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint)
sequences = [
    <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>,
    <span class="hljs-string">&quot;This course is amazing!&quot;</span>,
]
batch = <span class="hljs-built_in">dict</span>(tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>))

<span class="hljs-comment"># This is new</span>
model.<span class="hljs-built_in">compile</span>(optimizer=<span class="hljs-string">&quot;adam&quot;</span>, loss=<span class="hljs-string">&quot;sparse_categorical_crossentropy&quot;</span>)
labels = tf.convert_to_tensor([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>])
model.train_on_batch(batch, labels)`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=p,e=r(),J(i.$$.fragment)},l(c){t=j(c,"P",{"data-svelte-h":!0}),m(t)!=="svelte-kt80ar"&&(t.innerHTML=p),e=M(c),U(i.$$.fragment,c)},m(c,g){a(c,t,g),a(c,e,g),b(i,c,g),d=!0},i(c){d||(o(i.$$.fragment,c),d=!0)},o(c){y(i.$$.fragment,c),d=!1},d(c){c&&(n(t),n(e)),T(i,c)}}}function Ae(f){let t,p='这一小节学习<a href="/course/chapter2">第一小节</a>中提到的“如何使用模型中心（hub）大型数据集”，下面是我们用模型中心的数据在PyTorch上训练句子分类器的一个例子：',e,i,d;return i=new w({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQWRhbVclMkMlMjBBdXRvVG9rZW5pemVyJTJDJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQSUyMyUyMFNhbWUlMjBhcyUyMGJlZm9yZSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQXNlcXVlbmNlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMkkndmUlMjBiZWVuJTIwd2FpdGluZyUyMGZvciUyMGElMjBIdWdnaW5nRmFjZSUyMGNvdXJzZSUyMG15JTIwd2hvbGUlMjBsaWZlLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMlRoaXMlMjBjb3Vyc2UlMjBpcyUyMGFtYXppbmchJTIyJTJDJTBBJTVEJTBBYmF0Y2glMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwVGhpcyUyMGlzJTIwbmV3JTBBYmF0Y2glNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCMSUyQyUyMDElNUQpJTBBJTBBb3B0aW1pemVyJTIwJTNEJTIwQWRhbVcobW9kZWwucGFyYW1ldGVycygpKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmJhdGNoKS5sb3NzJTBBbG9zcy5iYWNrd2FyZCgpJTBBb3B0aW1pemVyLnN0ZXAoKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AdamW, AutoTokenizer, AutoModelForSequenceClassification

<span class="hljs-comment"># Same as before</span>
checkpoint = <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
sequences = [
    <span class="hljs-string">&quot;I&#x27;ve been waiting for a HuggingFace course my whole life.&quot;</span>,
    <span class="hljs-string">&quot;This course is amazing!&quot;</span>,
]
batch = tokenizer(sequences, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-comment"># This is new</span>
batch[<span class="hljs-string">&quot;labels&quot;</span>] = torch.tensor([<span class="hljs-number">1</span>, <span class="hljs-number">1</span>])

optimizer = AdamW(model.parameters())
loss = model(**batch).loss
loss.backward()
optimizer.step()`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=p,e=r(),J(i.$$.fragment)},l(c){t=j(c,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1xtlyjh"&&(t.innerHTML=p),e=M(c),U(i.$$.fragment,c)},m(c,g){a(c,t,g),a(c,e,g),b(i,c,g),d=!0},i(c){d||(o(i.$$.fragment,c),d=!0)},o(c){y(i.$$.fragment,c),d=!1},d(c){c&&(n(t),n(e)),T(i,c)}}}function Ge(f){let t,p;return t=new rl({props:{id:"W_gMJF0xomE"}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Qe(f){let t,p;return t=new rl({props:{id:"_BZearw7f0w"}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Be(f){let t,p="✏️ <strong>试试看！</strong> 查看训练集的第15行元素和验证集的87行元素。他们的标签是什么？";return{c(){t=u("p"),t.innerHTML=p},l(e){t=j(e,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1usx5xw"&&(t.innerHTML=p)},m(e,i){a(e,t,i)},p:wt,d(e){e&&n(t)}}}function Xe(f){let t,p;return t=new rl({props:{id:"P-rZWqcB6CE"}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function ve(f){let t,p;return t=new rl({props:{id:"0u3ioSwev3s"}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Ve(f){let t,p="✏️ <strong>试试看！</strong> 选取训练集中的第15个元素，将两句话分别标记为一对。结果和上方的例子有什么不同？";return{c(){t=u("p"),t.innerHTML=p},l(e){t=j(e,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1ttnljt"&&(t.innerHTML=p)},m(e,i){a(e,t,i)},p:wt,d(e){e&&n(t)}}}function We(f){let t,p="负责在批处理中将数据整理为一个batch的函数称为<em>collate函数</em>。它只会将您的样本转换为 tf.Tensor并将它们拼接起来(如果你的元素是列表、元组或字典，则会使用递归)。这在我们的这个例子中下是不可行的，因为我们的输入不是都是相同大小的。我们故意在之后每个batch上进行填充，避免有太多填充的过长的输入。这将大大加快训练速度，但请注意，如果你在TPU上训练，这可能会导致问题——TPU喜欢固定的形状，即使这需要额外的填充。";return{c(){t=u("p"),t.innerHTML=p},l(e){t=j(e,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1cdpvhz"&&(t.innerHTML=p)},m(e,i){a(e,t,i)},d(e){e&&n(t)}}}function ze(f){let t,p="负责在批处理中将数据整理为一个batch的函数称为<em>collate函数</em>。它是你可以在构建<strong>DataLoader</strong>时传递的一个参数，默认是一个函数，它将把你的数据集转换为PyTorch张量，并将它们拼接起来(如果你的元素是列表、元组或字典，则会使用递归)。这在我们的这个例子中下是不可行的，因为我们的输入不是都是相同大小的。我们故意在之后每个batch上进行填充，避免有太多填充的过长的输入。这将大大加快训练速度，但请注意，如果你在TPU上训练，这可能会导致问题——TPU喜欢固定的形状，即使这需要额外的填充。";return{c(){t=u("p"),t.innerHTML=p},l(e){t=j(e,"P",{"data-svelte-h":!0}),m(t)!=="svelte-alm93x"&&(t.innerHTML=p)},m(e,i){a(e,t,i)},d(e){e&&n(t)}}}function Ee(f){let t,p;return t=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function He(f){let t,p;return t=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`,wrap:!1}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Se(f){let t,p,e,i="看起来不错！现在，我们已经将原始文本转化为了模型可以处理的数据，我们已准备好对其进行微调！",d;return t=new w({props:{code:"JTdCJ2F0dGVudGlvbl9tYXNrJyUzQSUyMHRvcmNoLlNpemUoJTVCOCUyQyUyMDY3JTVEKSUyQyUwQSUyMCdpbnB1dF9pZHMnJTNBJTIwdG9yY2guU2l6ZSglNUI4JTJDJTIwNjclNUQpJTJDJTBBJTIwJ3Rva2VuX3R5cGVfaWRzJyUzQSUyMHRvcmNoLlNpemUoJTVCOCUyQyUyMDY3JTVEKSUyQyUwQSUyMCdsYWJlbHMnJTNBJTIwdG9yY2guU2l6ZSglNUI4JTVEKSU3RA==",highlighted:`{<span class="hljs-string">&#x27;attention_mask&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;input_ids&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: torch.Size([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;labels&#x27;</span>: torch.Size([<span class="hljs-number">8</span>])}`,wrap:!1}}),{c(){J(t.$$.fragment),p=r(),e=u("p"),e.textContent=i},l(c){U(t.$$.fragment,c),p=M(c),e=j(c,"P",{"data-svelte-h":!0}),m(e)!=="svelte-or9ziy"&&(e.textContent=i)},m(c,g){b(t,c,g),a(c,p,g),a(c,e,g),d=!0},i(c){d||(o(t.$$.fragment,c),d=!0)},o(c){y(t.$$.fragment,c),d=!1},d(c){c&&(n(p),n(e)),T(t,c)}}}function Ye(f){let t,p;return t=new w({props:{code:"JTdCJ2F0dGVudGlvbl9tYXNrJyUzQSUyMFRlbnNvclNoYXBlKCU1QjglMkMlMjA2NyU1RCklMkMlMEElMjAnaW5wdXRfaWRzJyUzQSUyMFRlbnNvclNoYXBlKCU1QjglMkMlMjA2NyU1RCklMkMlMEElMjAndG9rZW5fdHlwZV9pZHMnJTNBJTIwVGVuc29yU2hhcGUoJTVCOCUyQyUyMDY3JTVEKSUyQyUwQSUyMCdsYWJlbHMnJTNBJTIwVGVuc29yU2hhcGUoJTVCOCU1RCklN0Q=",highlighted:`{<span class="hljs-string">&#x27;attention_mask&#x27;</span>: TensorShape([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;input_ids&#x27;</span>: TensorShape([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: TensorShape([<span class="hljs-number">8</span>, <span class="hljs-number">67</span>]),
 <span class="hljs-string">&#x27;labels&#x27;</span>: TensorShape([<span class="hljs-number">8</span>])}`,wrap:!1}}),{c(){J(t.$$.fragment)},l(e){U(t.$$.fragment,e)},m(e,i){b(t,e,i),p=!0},i(e){p||(o(t.$$.fragment,e),p=!0)},o(e){y(t.$$.fragment,e),p=!1},d(e){T(t,e)}}}function Fe(f){let t,p="✏️ <strong>试试看！</strong> 在GLUE SST-2数据集上应用预处理。它有点不同，因为它是由单个句子而不是成对的句子组成的，但是我们所做的其他事情看起来应该是一样的。另一个更难的挑战，请尝试编写一个可用于任何GLUE任务的预处理函数。";return{c(){t=u("p"),t.innerHTML=p},l(e){t=j(e,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1m5uq1u"&&(t.innerHTML=p)},m(e,i){a(e,t,i)},p:wt,d(e){e&&n(t)}}}function de(f){let t,p="现在我们有了dataset和data collator，我们需要将dataset批量地应用data collator。 我们可以手动加载批次并整理它们，但这需要大量工作，而且可能性能也不是很好。 相反，有一个简单的方法可以为这个问题提供高效的解决方案：<code>to_tf_dataset()</code>。 这将在您的数据集上调用一个 <code>tf.data.Dataset</code>的方法，这个方法带有一个可选的data collator功能。 <code>tf.data.Dataset</code> 是 Keras 可用于 <code>model.fit()</code> 的原生 TensorFlow 格式，因此这种方法会立即将🤗 Dataset 转换为可用于训练的格式。 让我们看看它在我们的数据集上是如何使用的！",e,i,d,c,g="就是这样！ 我们可以将这些数据集带入下一节，在经过所有艰苦的数据预处理工作之后，训练将变得非常简单。",B;return i=new w({props:{code:"dGZfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnRvX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwY29sdW1ucyUzRCU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTJDJTIwJTIyaW5wdXRfaWRzJTIyJTJDJTIwJTIydG9rZW5fdHlwZV9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBsYWJlbF9jb2xzJTNEJTVCJTIybGFiZWxzJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0Q4JTJDJTBBKSUwQSUwQXRmX3ZhbGlkYXRpb25fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnZhbGlkYXRpb24lMjIlNUQudG9fdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjBjb2x1bW5zJTNEJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlMkMlMjAlMjJpbnB1dF9pZHMlMjIlMkMlMjAlMjJ0b2tlbl90eXBlX2lkcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGxhYmVsX2NvbHMlM0QlNUIlMjJsYWJlbHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSUyMCUyMCUyMCUyMGJhdGNoX3NpemUlM0Q4JTJDJTBBKQ==",highlighted:`tf_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    label_cols=[<span class="hljs-string">&quot;labels&quot;</span>],
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)

tf_validation_dataset = tokenized_datasets[<span class="hljs-string">&quot;validation&quot;</span>].to_tf_dataset(
    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;token_type_ids&quot;</span>],
    label_cols=[<span class="hljs-string">&quot;labels&quot;</span>],
    shuffle=<span class="hljs-literal">False</span>,
    collate_fn=data_collator,
    batch_size=<span class="hljs-number">8</span>,
)`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=p,e=r(),J(i.$$.fragment),d=r(),c=u("p"),c.textContent=g},l(h){t=j(h,"P",{"data-svelte-h":!0}),m(t)!=="svelte-1d9ldyd"&&(t.innerHTML=p),e=M(h),U(i.$$.fragment,h),d=M(h),c=j(h,"P",{"data-svelte-h":!0}),m(c)!=="svelte-cg0kxh"&&(c.textContent=g)},m(h,$){a(h,t,$),a(h,e,$),b(i,h,$),a(h,d,$),a(h,c,$),B=!0},i(h){B||(o(i.$$.fragment,h),B=!0)},o(h){y(i.$$.fragment,h),B=!1},d(h){h&&(n(t),n(e),n(d),n(c)),T(i,h)}}}function De(f){let t,p,e,i,d,c,g,B,h,$,Ks,k,C,Os,z,gt="当然，仅仅用两句话训练模型不会产生很好的效果。为了获得更好的结果，您需要准备一个更大的数据集。",Ml,E,_t='在本节中，我们将使用MRPC（微软研究释义语料库）数据集作为示例，该数据集由威廉·多兰和克里斯·布罗克特在<a href="https://www.aclweb.org/anthology/I05-5002.pdf" rel="nofollow">这篇文章</a>发布。该数据集由5801对句子组成，每个句子对带有一个标签，指示它们是否为同义（即，如果两个句子的意思相同）。我们在本章中选择了它，因为它是一个小数据集，所以很容易对它进行训练。',il,H,cl,x,I,sl,S,$t='模型中心（hub）不只是包含模型；它也有许多不同语言的多个数据集。点击<a href="https://huggingface.co/datasets" rel="nofollow">数据集</a>的链接即可进行浏览。我们建议您在阅读本节后阅读一下<a href="https://huggingface.co/docs/datasets/loading" rel="nofollow">加载和处理新的数据集</a>这篇文章，这会让您对huggingface的darasets更加清晰。但现在，让我们使用MRPC数据集中的<a href="https://gluebenchmark.com/" rel="nofollow">GLUE 基准测试数据集</a>，它是构成MRPC数据集的10个数据集之一，这是一个学术基准，用于衡量机器学习模型在10个不同文本分类任务中的性能。',ol,Y,kt="🤗 Datasets库提供了一个非常便捷的命令，可以在模型中心（hub）上下载和缓存数据集。我们可以通过以下的代码下载MRPC数据集：",yl,F,ul,D,jl,q,Ct="正如你所看到的，我们获得了一个<strong>DatasetDict</strong>对象，其中包含训练集、验证集和测试集。每一个集合都包含几个列(<strong>sentence1</strong>, <strong>sentence2</strong>, <strong>label</strong>, and <strong>idx</strong>)以及一个代表行数的变量，即每个集合中的行的个数（因此，训练集中有3668对句子，验证集中有408对，测试集中有1725对）。",ml,L,xt="默认情况下，此命令在下载数据集并缓存到 <strong>~/.cache/huggingface/datasets</strong>. 回想一下第2章，您可以通过设置<strong>HF_HOME</strong>环境变量来自定义缓存的文件夹。",Jl,P,It="我们可以访问我们数据集中的每一个<strong>raw_train_dataset</strong>对象，如使用字典：",Ul,K,bl,O,Tl,ss,Rt="我们可以看到标签已经是整数了，所以我们不需要对标签做任何预处理。要知道哪个数字对应于哪个标签，我们可以查看<strong>raw_train_dataset</strong>的<strong>features</strong>. 这将告诉我们每列的类型：",fl,ls,hl,ts,dl,es,Zt="在上面的例子之中,<strong>Label（标签）</strong> 是一种<strong>ClassLabel（分类标签）</strong>，使用整数建立起到类别标签的映射关系。<strong>0</strong>对应于<strong>not_equivalent</strong>，<strong>1</strong>对应于<strong>equivalent</strong>。",wl,v,gl,ns,_l,R,Z,ll,as,Nt='为了预处理数据集，我们需要将文本转换为模型能够理解的数字。正如你在<a href="/course/chapter2">第二章</a>上看到的那样',$l,ps,kl,rs,At="然而，在两句话传递给模型，预测这两句话是否是同义之前。我们需要这两句话依次进行适当的预处理。幸运的是，标记器不仅仅可以输入单个句子还可以输入一组句子，并按照我们的BERT模型所期望的输入进行处理：",Cl,Ms,xl,is,Il,cs,Gt='我们在<a href="/course/chapter2">第二章</a> 讨论了<strong>输入词id(input_ids)</strong> 和 <strong>注意力遮罩(attention_mask)</strong> ，但我们在那个时候没有讨论<strong>类型标记ID(token_type_ids)</strong>。在这个例子中，<strong>类型标记ID(token_type_ids)</strong>的作用就是告诉模型输入的哪一部分是第一句，哪一部分是第二句。',Rl,V,Zl,os,Qt="如果我们将<strong>input_ids</strong>中的id转换回文字:",Nl,ys,Al,us,Bt="我们将得到：",Gl,js,Ql,ms,Xt="所以我们看到模型需要输入的形式是 <strong>[CLS] sentence1 [SEP] sentence2 [SEP]</strong>。因此，当有两句话的时候。<strong>类型标记ID(token_type_ids)</strong> 的值是：",Bl,Js,Xl,Us,vt="如您所见，输入中 <strong>[CLS] sentence1 [SEP]</strong> 它们的类型标记ID均为<strong>0</strong>，而其他部分，对应于<strong>sentence2 [SEP]</strong>，所有的类型标记ID均为<strong>1</strong>.",vl,bs,Vt="请注意，如果选择其他的检查点，则不一定具有<strong>类型标记ID(token_type_ids)</strong>（例如，如果使用DistilBERT模型，就不会返回它们）。只有当它在预训练期间使用过这一层，模型在构建时依赖它们，才会返回它们。",Vl,Ts,Wt='用类型标记ID对BERT进行预训练,并且使用<a href="/course/chapter1">第一章</a>的遮罩语言模型，还有一个额外的应用类型，叫做下一句预测. 这项任务的目标是建立成对句子之间关系的模型。',Wl,fs,zt="在下一个句子预测任务中，会给模型输入成对的句子（带有随机遮罩的标记），并被要求预测第二个句子是否紧跟第一个句子。为了提高模型的泛化能力，数据集中一半的两个句子在原始文档中挨在一起，另一半的两个句子来自两个不同的文档。",zl,hs,Et="一般来说，你不需要担心是否有<strong>类型标记ID(token_type_ids)</strong>。在您的标输入中：只要您对标记器和模型使用相同的检查点，一切都会很好，因为标记器知道向其模型提供什么。",El,ds,Ht='现在我们已经了解了标记器如何处理一对句子，我们可以使用它对整个数据集进行处理：如<a href="/course/chapter2">之前的章节</a>，我们可以给标记器提供一组句子，第一个参数是它第一个句子的列表，第二个参数是第二个句子的列表。这也与我们在<a href="/course/chapter2">第二章</a>中看到的填充和截断选项兼容. 因此，预处理训练数据集的一种方法是：',Hl,ws,Sl,gs,St='这很有效，但它的缺点是返回字典（字典的键是<strong>输入词id(input_ids)</strong> ， <strong>注意力遮罩(attention_mask)</strong> 和 <strong>类型标记ID(token_type_ids)</strong>，字典的值是键所对应值的列表）。而且只有当您在转换过程中有足够的内存来存储整个数据集时才不会出错（而🤗数据集库中的数据集是以<a href="https://arrow.apache.org/" rel="nofollow">Apache Arrow</a>文件存储在磁盘上，因此您只需将接下来要用的数据加载在内存中，因此会对内存容量的需求要低一些）。',Yl,_s,Yt='为了将数据保存为数据集，我们将使用<a href="https://huggingface.co/docs/datasets/package_reference/main_classes#datasets.Dataset.map" rel="nofollow">Dataset.map()</a>方法，如果我们需要做更多的预处理而不仅仅是标记化，那么这也给了我们一些额外的自定义的方法。这个方法的工作原理是在数据集的每个元素上应用一个函数，因此让我们定义一个标记输入的函数：',Fl,$s,Dl,ks,Ft='此函数的输入是一个字典（与数据集的项类似），并返回一个包含<strong>输入词id(input_ids)</strong> ， <strong>注意力遮罩(attention_mask)</strong> 和 <strong>类型标记ID(token_type_ids)</strong> 键的新字典。请注意，如果像上面的<strong>示例</strong>一样，如果键所对应的值包含多个句子（每个键作为一个句子列表），那么它依然可以工作，就像前面的例子一样标记器可以处理成对的句子列表。这样的话我们可以在调用<strong>map()</strong>使用该选项 <strong>batched=True</strong> ，这将显著加快标记与标记的速度。这个<strong>标记器</strong>来自<a href="https://github.com/huggingface/tokenizers" rel="nofollow">🤗 Tokenizers</a>库由Rust编写而成。当我们一次给它大量的输入时，这个标记器可以非常快。',ql,Cs,Dt="请注意，我们现在在标记函数中省略了<strong>padding</strong>参数。这是因为在标记的时候将所有样本填充到最大长度的效率不高。一个更好的做法：在构建批处理时填充样本更好，因为这样我们只需要填充到该批处理中的最大长度，而不是整个数据集的最大长度。当输入长度变化很大时，这可以节省大量时间和处理能力!",Ll,xs,qt="下面是我们如何在所有数据集上同时应用标记函数。我们在调用<strong>map</strong>时使用了<strong>batch =True</strong>，这样函数就可以同时应用到数据集的多个元素上，而不是分别应用到每个元素上。这将使我们的预处理快许多",Pl,Is,Kl,Rs,Lt="🤗Datasets库应用这种处理的方式是向数据集添加新的字段，每个字段对应预处理函数返回的字典中的每个键:",Ol,Zs,st,Ns,Pt="在使用预处理函数<strong>map()</strong>时，甚至可以通过传递<strong>num_proc</strong>参数使用并行处理。我们在这里没有这样做，因为🤗标记器库已经使用多个线程来更快地标记我们的样本，但是如果您没有使用该库支持的快速标记器，使用<strong>num_proc</strong>可能会加快预处理。",lt,As,Kt="我们的<strong>标记函数(tokenize_function)</strong>返回包含<strong>输入词id(input_ids)</strong> ， <strong>注意力遮罩(attention_mask)</strong> 和 <strong>类型标记ID(token_type_ids)</strong> 键的字典,所以这三个字段被添加到数据集的标记的结果中。注意，如果预处理函数<strong>map()</strong>为现有键返回一个新值，那将会修改原有键的值。",tt,Gs,Ot="最后一件我们需要做的事情是，当我们一起批处理元素时，将所有示例填充到最长元素的长度——我们称之为动态填充。",et,Qs,nt,Bs,at,tl,Xs,se="为了解决句子长度统一的问题，我们必须定义一个collate函数，该函数会将每个batch句子填充到正确的长度。幸运的是，🤗transformer库通过<strong>DataCollatorWithPadding</strong>为我们提供了这样一个函数。当你实例化它时，需要一个标记器(用来知道使用哪个词来填充，以及模型期望填充在左边还是右边)，并将做你需要的一切:",pt,N,A,el,vs,le="为了测试这个新玩具，让我们从我们的训练集中抽取几个样本。这里，我们删除列<strong>idx</strong>, <strong>sentence1</strong>和<strong>sentence2</strong>，因为不需要它们，并查看一个batch中每个条目的长度:",rt,Vs,Mt,Ws,it,zs,te="毫无疑问，我们得到了不同长度的样本，从32到67。动态填充意味着该批中的所有样本都应该填充到长度为67，这是该批中的最大长度。如果没有动态填充，所有的样本都必须填充到整个数据集中的最大长度，或者模型可以接受的最大长度。让我们再次检查<strong>data_collator</strong>是否正确地动态填充了这批样本：",ct,Es,ot,G,Q,nl,W,yt,al,pl,ut;d=new Ie({props:{fw:f[0]}}),g=new mt({props:{title:"处理数据",local:"处理数据",headingTag:"h1"}});const ee=[Ze,Re],Hs=[];function ne(s,l){return s[0]==="pt"?0:1}h=ne(f),$=Hs[h]=ee[h](f);const ae=[Ae,Ne],Ss=[];function pe(s,l){return s[0]==="pt"?0:1}k=pe(f),C=Ss[k]=ae[k](f),H=new mt({props:{title:"从模型中心（Hub）加载数据集",local:"从模型中心（Hub）加载数据集",headingTag:"h3"}});const re=[Qe,Ge],Ys=[];function Me(s,l){return s[0]==="pt"?0:1}x=Me(f),I=Ys[x]=re[x](f),F=new w({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBcmF3X2RhdGFzZXRzJTIwJTNEJTIwbG9hZF9kYXRhc2V0KCUyMmdsdWUlMjIlMkMlMjAlMjJtcnBjJTIyKSUwQXJhd19kYXRhc2V0cw==",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

raw_datasets = load_dataset(<span class="hljs-string">&quot;glue&quot;</span>, <span class="hljs-string">&quot;mrpc&quot;</span>)
raw_datasets`,wrap:!1}}),D=new w({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ3NlbnRlbmNlMSclMkMlMjAnc2VudGVuY2UyJyUyQyUyMCdsYWJlbCclMkMlMjAnaWR4JyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMzY2OCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB2YWxpZGF0aW9uJTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidzZW50ZW5jZTEnJTJDJTIwJ3NlbnRlbmNlMiclMkMlMjAnbGFiZWwnJTJDJTIwJ2lkeCclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDQwOCUwQSUyMCUyMCUyMCUyMCU3RCklMEElMjAlMjAlMjAlMjB0ZXN0JTNBJTIwRGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidzZW50ZW5jZTEnJTJDJTIwJ3NlbnRlbmNlMiclMkMlMjAnbGFiZWwnJTJDJTIwJ2lkeCclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDE3MjUlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTdEKQ==",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>],
        num_rows: <span class="hljs-number">3668</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>],
        num_rows: <span class="hljs-number">408</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>],
        num_rows: <span class="hljs-number">1725</span>
    })
})`,wrap:!1}}),K=new w({props:{code:"cmF3X3RyYWluX2RhdGFzZXQlMjAlM0QlMjByYXdfZGF0YXNldHMlNUIlMjJ0cmFpbiUyMiU1RCUwQXJhd190cmFpbl9kYXRhc2V0JTVCMCU1RA==",highlighted:`raw_train_dataset = raw_datasets[<span class="hljs-string">&quot;train&quot;</span>]
raw_train_dataset[<span class="hljs-number">0</span>]`,wrap:!1}}),O=new w({props:{code:"JTdCJ2lkeCclM0ElMjAwJTJDJTBBJTIwJ2xhYmVsJyUzQSUyMDElMkMlMEElMjAnc2VudGVuY2UxJyUzQSUyMCdBbXJvemklMjBhY2N1c2VkJTIwaGlzJTIwYnJvdGhlciUyMCUyQyUyMHdob20lMjBoZSUyMGNhbGxlZCUyMCUyMiUyMHRoZSUyMHdpdG5lc3MlMjAlMjIlMjAlMkMlMjBvZiUyMGRlbGliZXJhdGVseSUyMGRpc3RvcnRpbmclMjBoaXMlMjBldmlkZW5jZSUyMC4nJTJDJTBBJTIwJ3NlbnRlbmNlMiclM0ElMjAnUmVmZXJyaW5nJTIwdG8lMjBoaW0lMjBhcyUyMG9ubHklMjAlMjIlMjB0aGUlMjB3aXRuZXNzJTIwJTIyJTIwJTJDJTIwQW1yb3ppJTIwYWNjdXNlZCUyMGhpcyUyMGJyb3RoZXIlMjBvZiUyMGRlbGliZXJhdGVseSUyMGRpc3RvcnRpbmclMjBoaXMlMjBldmlkZW5jZSUyMC4nJTdE",highlighted:`{<span class="hljs-string">&#x27;idx&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">1</span>,
 <span class="hljs-string">&#x27;sentence1&#x27;</span>: <span class="hljs-string">&#x27;Amrozi accused his brother , whom he called &quot; the witness &quot; , of deliberately distorting his evidence .&#x27;</span>,
 <span class="hljs-string">&#x27;sentence2&#x27;</span>: <span class="hljs-string">&#x27;Referring to him as only &quot; the witness &quot; , Amrozi accused his brother of deliberately distorting his evidence .&#x27;</span>}`,wrap:!1}}),ls=new w({props:{code:"cmF3X3RyYWluX2RhdGFzZXQuZmVhdHVyZXM=",highlighted:"raw_train_dataset.features",wrap:!1}}),ts=new w({props:{code:"JTdCJ3NlbnRlbmNlMSclM0ElMjBWYWx1ZShkdHlwZSUzRCdzdHJpbmcnJTJDJTIwaWQlM0ROb25lKSUyQyUwQSUyMCdzZW50ZW5jZTInJTNBJTIwVmFsdWUoZHR5cGUlM0Qnc3RyaW5nJyUyQyUyMGlkJTNETm9uZSklMkMlMEElMjAnbGFiZWwnJTNBJTIwQ2xhc3NMYWJlbChudW1fY2xhc3NlcyUzRDIlMkMlMjBuYW1lcyUzRCU1Qidub3RfZXF1aXZhbGVudCclMkMlMjAnZXF1aXZhbGVudCclNUQlMkMlMjBuYW1lc19maWxlJTNETm9uZSUyQyUyMGlkJTNETm9uZSklMkMlMEElMjAnaWR4JyUzQSUyMFZhbHVlKGR0eXBlJTNEJ2ludDMyJyUyQyUyMGlkJTNETm9uZSklN0Q=",highlighted:`{<span class="hljs-string">&#x27;sentence1&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>),
 <span class="hljs-string">&#x27;sentence2&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;string&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>),
 <span class="hljs-string">&#x27;label&#x27;</span>: ClassLabel(num_classes=<span class="hljs-number">2</span>, names=[<span class="hljs-string">&#x27;not_equivalent&#x27;</span>, <span class="hljs-string">&#x27;equivalent&#x27;</span>], names_file=<span class="hljs-literal">None</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>),
 <span class="hljs-string">&#x27;idx&#x27;</span>: Value(dtype=<span class="hljs-string">&#x27;int32&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)}`,wrap:!1}}),v=new dt({props:{$$slots:{default:[Be]},$$scope:{ctx:f}}}),ns=new mt({props:{title:"预处理数据集",local:"预处理数据集",headingTag:"h3"}});const ie=[ve,Xe],Fs=[];function ce(s,l){return s[0]==="pt"?0:1}R=ce(f),Z=Fs[R]=ie[R](f),ps=new w({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQXRva2VuaXplZF9zZW50ZW5jZXNfMSUyMCUzRCUyMHRva2VuaXplcihyYXdfZGF0YXNldHMlNUIlMjJ0cmFpbiUyMiU1RCU1QiUyMnNlbnRlbmNlMSUyMiU1RCklMEF0b2tlbml6ZWRfc2VudGVuY2VzXzIlMjAlM0QlMjB0b2tlbml6ZXIocmF3X2RhdGFzZXRzJTVCJTIydHJhaW4lMjIlNUQlNUIlMjJzZW50ZW5jZTIlMjIlNUQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

checkpoint = <span class="hljs-string">&quot;bert-base-uncased&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
tokenized_sentences_1 = tokenizer(raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-string">&quot;sentence1&quot;</span>])
tokenized_sentences_2 = tokenizer(raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-string">&quot;sentence2&quot;</span>])`,wrap:!1}}),Ms=new w({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlRoaXMlMjBpcyUyMHRoZSUyMGZpcnN0JTIwc2VudGVuY2UuJTIyJTJDJTIwJTIyVGhpcyUyMGlzJTIwdGhlJTIwc2Vjb25kJTIwb25lLiUyMiklMEFpbnB1dHM=",highlighted:`inputs = tokenizer(<span class="hljs-string">&quot;This is the first sentence.&quot;</span>, <span class="hljs-string">&quot;This is the second one.&quot;</span>)
inputs`,wrap:!1}}),is=new w({props:{code:"JTdCJTIwJTBBJTIwJTIwJ2lucHV0X2lkcyclM0ElMjAlNUIxMDElMkMlMjAyMDIzJTJDJTIwMjAwMyUyQyUyMDE5OTYlMkMlMjAyMDM0JTJDJTIwNjI1MSUyQyUyMDEwMTIlMkMlMjAxMDIlMkMlMjAyMDIzJTJDJTIwMjAwMyUyQyUyMDE5OTYlMkMlMjAyMTE3JTJDJTIwMjAyOCUyQyUyMDEwMTIlMkMlMjAxMDIlNUQlMkMlMEElMjAlMjAndG9rZW5fdHlwZV9pZHMnJTNBJTIwJTVCMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTVEJTJDJTBBJTIwJTIwJ2F0dGVudGlvbl9tYXNrJyUzQSUyMCU1QjElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSU1RCUwQSU3RA==",highlighted:`{ 
  <span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">2023</span>, <span class="hljs-number">2003</span>, <span class="hljs-number">1996</span>, <span class="hljs-number">2034</span>, <span class="hljs-number">6251</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>, <span class="hljs-number">2023</span>, <span class="hljs-number">2003</span>, <span class="hljs-number">1996</span>, <span class="hljs-number">2117</span>, <span class="hljs-number">2028</span>, <span class="hljs-number">1012</span>, <span class="hljs-number">102</span>],
  <span class="hljs-string">&#x27;token_type_ids&#x27;</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">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],
  <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]
}`,wrap:!1}}),V=new dt({props:{$$slots:{default:[Ve]},$$scope:{ctx:f}}}),ys=new w({props:{code:"dG9rZW5pemVyLmNvbnZlcnRfaWRzX3RvX3Rva2VucyhpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQp",highlighted:'tokenizer.convert_ids_to_tokens(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])',wrap:!1}}),js=new w({props:{code:"JTVCJyU1QkNMUyU1RCclMkMlMjAndGhpcyclMkMlMjAnaXMnJTJDJTIwJ3RoZSclMkMlMjAnZmlyc3QnJTJDJTIwJ3NlbnRlbmNlJyUyQyUyMCcuJyUyQyUyMCclNUJTRVAlNUQnJTJDJTIwJ3RoaXMnJTJDJTIwJ2lzJyUyQyUyMCd0aGUnJTJDJTIwJ3NlY29uZCclMkMlMjAnb25lJyUyQyUyMCcuJyUyQyUyMCclNUJTRVAlNUQnJTVE",highlighted:'[<span class="hljs-string">&#x27;[CLS]&#x27;</span>, <span class="hljs-string">&#x27;this&#x27;</span>, <span class="hljs-string">&#x27;is&#x27;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;first&#x27;</span>, <span class="hljs-string">&#x27;sentence&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>, <span class="hljs-string">&#x27;this&#x27;</span>, <span class="hljs-string">&#x27;is&#x27;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;second&#x27;</span>, <span class="hljs-string">&#x27;one&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>]',wrap:!1}}),Js=new w({props:{code:"JTVCJyU1QkNMUyU1RCclMkMlMjAndGhpcyclMkMlMjAnaXMnJTJDJTIwJ3RoZSclMkMlMjAnZmlyc3QnJTJDJTIwJ3NlbnRlbmNlJyUyQyUyMCcuJyUyQyUyMCclNUJTRVAlNUQnJTJDJTIwJ3RoaXMnJTJDJTIwJ2lzJyUyQyUyMCd0aGUnJTJDJTIwJ3NlY29uZCclMkMlMjAnb25lJyUyQyUyMCcuJyUyQyUyMCclNUJTRVAlNUQnJTVEJTBBJTVCJTIwJTIwJTIwJTIwJTIwJTIwMCUyQyUyMCUyMCUyMCUyMCUyMCUyMDAlMkMlMjAlMjAlMjAlMjAwJTJDJTIwJTIwJTIwJTIwJTIwMCUyQyUyMCUyMCUyMCUyMCUyMCUyMCUyMDAlMkMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAwJTJDJTIwJTIwJTIwMCUyQyUyMCUyMCUyMCUyMCUyMCUyMCUyMDAlMkMlMjAlMjAlMjAlMjAlMjAlMjAxJTJDJTIwJTIwJTIwJTIwMSUyQyUyMCUyMCUyMCUyMCUyMDElMkMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAxJTJDJTIwJTIwJTIwJTIwJTIwMSUyQyUyMCUyMCUyMDElMkMlMjAlMjAlMjAlMjAlMjAlMjAlMjAxJTVE",highlighted:`[<span class="hljs-string">&#x27;[CLS]&#x27;</span>, <span class="hljs-string">&#x27;this&#x27;</span>, <span class="hljs-string">&#x27;is&#x27;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;first&#x27;</span>, <span class="hljs-string">&#x27;sentence&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</span>, <span class="hljs-string">&#x27;this&#x27;</span>, <span class="hljs-string">&#x27;is&#x27;</span>, <span class="hljs-string">&#x27;the&#x27;</span>, <span class="hljs-string">&#x27;second&#x27;</span>, <span class="hljs-string">&#x27;one&#x27;</span>, <span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;[SEP]&#x27;</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">0</span>,          <span class="hljs-number">0</span>,   <span class="hljs-number">0</span>,       <span class="hljs-number">0</span>,      <span class="hljs-number">1</span>,    <span class="hljs-number">1</span>,     <span class="hljs-number">1</span>,        <span class="hljs-number">1</span>,     <span class="hljs-number">1</span>,   <span class="hljs-number">1</span>,       <span class="hljs-number">1</span>]`,wrap:!1}}),ws=new w({props:{code:"dG9rZW5pemVkX2RhdGFzZXQlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwcmF3X2RhdGFzZXRzJTVCJTIydHJhaW4lMjIlNUQlNUIlMjJzZW50ZW5jZTElMjIlNUQlMkMlMEElMjAlMjAlMjAlMjByYXdfZGF0YXNldHMlNUIlMjJ0cmFpbiUyMiU1RCU1QiUyMnNlbnRlbmNlMiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMEEp",highlighted:`tokenized_dataset = tokenizer(
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-string">&quot;sentence1&quot;</span>],
    raw_datasets[<span class="hljs-string">&quot;train&quot;</span>][<span class="hljs-string">&quot;sentence2&quot;</span>],
    padding=<span class="hljs-literal">True</span>,
    truncation=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),$s=new w({props:{code:"ZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZSklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoZXhhbXBsZSU1QiUyMnNlbnRlbmNlMSUyMiU1RCUyQyUyMGV4YW1wbGUlNUIlMjJzZW50ZW5jZTIlMjIlNUQlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_function</span>(<span class="hljs-params">example</span>):
    <span class="hljs-keyword">return</span> tokenizer(example[<span class="hljs-string">&quot;sentence1&quot;</span>], example[<span class="hljs-string">&quot;sentence2&quot;</span>], truncation=<span class="hljs-literal">True</span>)`,wrap:!1}}),Is=new w({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwcmF3X2RhdGFzZXRzLm1hcCh0b2tlbml6ZV9mdW5jdGlvbiUyQyUyMGJhdGNoZWQlM0RUcnVlKSUwQXRva2VuaXplZF9kYXRhc2V0cw==",highlighted:`tokenized_datasets = raw_datasets.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)
tokenized_datasets`,wrap:!1}}),Zs=new w({props:{code:"RGF0YXNldERpY3QoJTdCJTBBJTIwJTIwJTIwJTIwdHJhaW4lM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpZHgnJTJDJTIwJ2lucHV0X2lkcyclMkMlMjAnbGFiZWwnJTJDJTIwJ3NlbnRlbmNlMSclMkMlMjAnc2VudGVuY2UyJyUyQyUyMCd0b2tlbl90eXBlX2lkcyclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDM2NjglMEElMjAlMjAlMjAlMjAlN0QpJTBBJTIwJTIwJTIwJTIwdmFsaWRhdGlvbiUzQSUyMERhdGFzZXQoJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZmVhdHVyZXMlM0ElMjAlNUInYXR0ZW50aW9uX21hc2snJTJDJTIwJ2lkeCclMkMlMjAnaW5wdXRfaWRzJyUyQyUyMCdsYWJlbCclMkMlMjAnc2VudGVuY2UxJyUyQyUyMCdzZW50ZW5jZTInJTJDJTIwJ3Rva2VuX3R5cGVfaWRzJyU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNDA4JTBBJTIwJTIwJTIwJTIwJTdEKSUwQSUyMCUyMCUyMCUyMHRlc3QlM0ElMjBEYXRhc2V0KCU3QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGZlYXR1cmVzJTNBJTIwJTVCJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdpZHgnJTJDJTIwJ2lucHV0X2lkcyclMkMlMjAnbGFiZWwnJTJDJTIwJ3NlbnRlbmNlMSclMkMlMjAnc2VudGVuY2UyJyUyQyUyMCd0b2tlbl90eXBlX2lkcyclNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDE3MjUlMEElMjAlMjAlMjAlMjAlN0QpJTBBJTdEKQ==",highlighted:`DatasetDict({
    train: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;token_type_ids&#x27;</span>],
        num_rows: <span class="hljs-number">3668</span>
    })
    validation: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;token_type_ids&#x27;</span>],
        num_rows: <span class="hljs-number">408</span>
    })
    test: Dataset({
        features: [<span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;idx&#x27;</span>, <span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>, <span class="hljs-string">&#x27;sentence1&#x27;</span>, <span class="hljs-string">&#x27;sentence2&#x27;</span>, <span class="hljs-string">&#x27;token_type_ids&#x27;</span>],
        num_rows: <span class="hljs-number">1725</span>
    })
})`,wrap:!1}}),Qs=new mt({props:{title:"动态填充",local:"动态填充",headingTag:"h3"}}),Bs=new rl({props:{id:"7q5NyFT8REg"}});function oe(s,l){return s[0]==="pt"?ze:We}let jt=oe(f),X=jt(f);const ye=[He,Ee],Ds=[];function ue(s,l){return s[0]==="pt"?0:1}N=ue(f),A=Ds[N]=ye[N](f),Vs=new w({props:{code:"c2FtcGxlcyUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVEJTVCJTNBOCU1RCUwQXNhbXBsZXMlMjAlM0QlMjAlN0JrJTNBJTIwdiUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBzYW1wbGVzLml0ZW1zKCklMjBpZiUyMGslMjBub3QlMjBpbiUyMCU1QiUyMmlkeCUyMiUyQyUyMCUyMnNlbnRlbmNlMSUyMiUyQyUyMCUyMnNlbnRlbmNlMiUyMiU1RCU3RCUwQSU1Qmxlbih4KSUyMGZvciUyMHglMjBpbiUyMHNhbXBsZXMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlNUQ=",highlighted:`samples = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>][:<span class="hljs-number">8</span>]
samples = {k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> samples.items() <span class="hljs-keyword">if</span> k <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;idx&quot;</span>, <span class="hljs-string">&quot;sentence1&quot;</span>, <span class="hljs-string">&quot;sentence2&quot;</span>]}
[<span class="hljs-built_in">len</span>(x) <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> samples[<span class="hljs-string">&quot;input_ids&quot;</span>]]`,wrap:!1}}),Ws=new w({props:{code:"JTVCNTAlMkMlMjA1OSUyQyUyMDQ3JTJDJTIwNjclMkMlMjA1OSUyQyUyMDUwJTJDJTIwNjIlMkMlMjAzMiU1RA==",highlighted:'[<span class="hljs-number">50</span>, <span class="hljs-number">59</span>, <span class="hljs-number">47</span>, <span class="hljs-number">67</span>, <span class="hljs-number">59</span>, <span class="hljs-number">50</span>, <span class="hljs-number">62</span>, <span class="hljs-number">32</span>]',wrap:!1}}),Es=new w({props:{code:"JTBBJTYwJTYwJTYwcHklMEFiYXRjaCUyMCUzRCUyMGRhdGFfY29sbGF0b3Ioc2FtcGxlcyklMEElN0JrJTNBJTIwdi5zaGFwZSUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBiYXRjaC5pdGVtcygpJTdE",highlighted:'\n```py\nbatch = dat<span class="hljs-built_in">a_collator</span>(samples)\n<span class="hljs-title">{k:</span> v.shape for k, v in batch.items()}',wrap:!1}});const je=[Ye,Se],qs=[];function me(s,l){return s[0]==="tf"?0:1}G=me(f),Q=qs[G]=je[G](f),W=new dt({props:{$$slots:{default:[Fe]},$$scope:{ctx:f}}});let _=f[0]==="tf"&&de();return{c(){t=u("meta"),p=r(),e=u("p"),i=r(),J(d.$$.fragment),c=r(),J(g.$$.fragment),B=r(),$.c(),Ks=r(),C.c(),Os=r(),z=u("p"),z.textContent=gt,Ml=r(),E=u("p"),E.innerHTML=_t,il=r(),J(H.$$.fragment),cl=r(),I.c(),sl=r(),S=u("p"),S.innerHTML=$t,ol=r(),Y=u("p"),Y.textContent=kt,yl=r(),J(F.$$.fragment),ul=r(),J(D.$$.fragment),jl=r(),q=u("p"),q.innerHTML=Ct,ml=r(),L=u("p"),L.innerHTML=xt,Jl=r(),P=u("p"),P.innerHTML=It,Ul=r(),J(K.$$.fragment),bl=r(),J(O.$$.fragment),Tl=r(),ss=u("p"),ss.innerHTML=Rt,fl=r(),J(ls.$$.fragment),hl=r(),J(ts.$$.fragment),dl=r(),es=u("p"),es.innerHTML=Zt,wl=r(),J(v.$$.fragment),gl=r(),J(ns.$$.fragment),_l=r(),Z.c(),ll=r(),as=u("p"),as.innerHTML=Nt,$l=r(),J(ps.$$.fragment),kl=r(),rs=u("p"),rs.textContent=At,Cl=r(),J(Ms.$$.fragment),xl=r(),J(is.$$.fragment),Il=r(),cs=u("p"),cs.innerHTML=Gt,Rl=r(),J(V.$$.fragment),Zl=r(),os=u("p"),os.innerHTML=Qt,Nl=r(),J(ys.$$.fragment),Al=r(),us=u("p"),us.textContent=Bt,Gl=r(),J(js.$$.fragment),Ql=r(),ms=u("p"),ms.innerHTML=Xt,Bl=r(),J(Js.$$.fragment),Xl=r(),Us=u("p"),Us.innerHTML=vt,vl=r(),bs=u("p"),bs.innerHTML=Vt,Vl=r(),Ts=u("p"),Ts.innerHTML=Wt,Wl=r(),fs=u("p"),fs.textContent=zt,zl=r(),hs=u("p"),hs.innerHTML=Et,El=r(),ds=u("p"),ds.innerHTML=Ht,Hl=r(),J(ws.$$.fragment),Sl=r(),gs=u("p"),gs.innerHTML=St,Yl=r(),_s=u("p"),_s.innerHTML=Yt,Fl=r(),J($s.$$.fragment),Dl=r(),ks=u("p"),ks.innerHTML=Ft,ql=r(),Cs=u("p"),Cs.innerHTML=Dt,Ll=r(),xs=u("p"),xs.innerHTML=qt,Pl=r(),J(Is.$$.fragment),Kl=r(),Rs=u("p"),Rs.textContent=Lt,Ol=r(),J(Zs.$$.fragment),st=r(),Ns=u("p"),Ns.innerHTML=Pt,lt=r(),As=u("p"),As.innerHTML=Kt,tt=r(),Gs=u("p"),Gs.textContent=Ot,et=r(),J(Qs.$$.fragment),nt=r(),J(Bs.$$.fragment),at=r(),X.c(),tl=r(),Xs=u("p"),Xs.innerHTML=se,pt=r(),A.c(),el=r(),vs=u("p"),vs.innerHTML=le,rt=r(),J(Vs.$$.fragment),Mt=r(),J(Ws.$$.fragment),it=r(),zs=u("p"),zs.innerHTML=te,ct=r(),J(Es.$$.fragment),ot=r(),Q.c(),nl=r(),J(W.$$.fragment),yt=r(),_&&_.c(),al=r(),pl=u("p"),this.h()},l(s){const l=Ce("svelte-u9bgzb",document.head);t=j(l,"META",{name:!0,content:!0}),l.forEach(n),p=M(s),e=j(s,"P",{}),fe(e).forEach(n),i=M(s),U(d.$$.fragment,s),c=M(s),U(g.$$.fragment,s),B=M(s),$.l(s),Ks=M(s),C.l(s),Os=M(s),z=j(s,"P",{"data-svelte-h":!0}),m(z)!=="svelte-drmjm8"&&(z.textContent=gt),Ml=M(s),E=j(s,"P",{"data-svelte-h":!0}),m(E)!=="svelte-fe15wv"&&(E.innerHTML=_t),il=M(s),U(H.$$.fragment,s),cl=M(s),I.l(s),sl=M(s),S=j(s,"P",{"data-svelte-h":!0}),m(S)!=="svelte-ncgqns"&&(S.innerHTML=$t),ol=M(s),Y=j(s,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-r34sn4"&&(Y.textContent=kt),yl=M(s),U(F.$$.fragment,s),ul=M(s),U(D.$$.fragment,s),jl=M(s),q=j(s,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1oj59g2"&&(q.innerHTML=Ct),ml=M(s),L=j(s,"P",{"data-svelte-h":!0}),m(L)!=="svelte-pv8csc"&&(L.innerHTML=xt),Jl=M(s),P=j(s,"P",{"data-svelte-h":!0}),m(P)!=="svelte-15kj1js"&&(P.innerHTML=It),Ul=M(s),U(K.$$.fragment,s),bl=M(s),U(O.$$.fragment,s),Tl=M(s),ss=j(s,"P",{"data-svelte-h":!0}),m(ss)!=="svelte-19kpezu"&&(ss.innerHTML=Rt),fl=M(s),U(ls.$$.fragment,s),hl=M(s),U(ts.$$.fragment,s),dl=M(s),es=j(s,"P",{"data-svelte-h":!0}),m(es)!=="svelte-ocxmcv"&&(es.innerHTML=Zt),wl=M(s),U(v.$$.fragment,s),gl=M(s),U(ns.$$.fragment,s),_l=M(s),Z.l(s),ll=M(s),as=j(s,"P",{"data-svelte-h":!0}),m(as)!=="svelte-2tqoru"&&(as.innerHTML=Nt),$l=M(s),U(ps.$$.fragment,s),kl=M(s),rs=j(s,"P",{"data-svelte-h":!0}),m(rs)!=="svelte-ofjmes"&&(rs.textContent=At),Cl=M(s),U(Ms.$$.fragment,s),xl=M(s),U(is.$$.fragment,s),Il=M(s),cs=j(s,"P",{"data-svelte-h":!0}),m(cs)!=="svelte-10bulny"&&(cs.innerHTML=Gt),Rl=M(s),U(V.$$.fragment,s),Zl=M(s),os=j(s,"P",{"data-svelte-h":!0}),m(os)!=="svelte-1quodij"&&(os.innerHTML=Qt),Nl=M(s),U(ys.$$.fragment,s),Al=M(s),us=j(s,"P",{"data-svelte-h":!0}),m(us)!=="svelte-gglnbk"&&(us.textContent=Bt),Gl=M(s),U(js.$$.fragment,s),Ql=M(s),ms=j(s,"P",{"data-svelte-h":!0}),m(ms)!=="svelte-1s11yzb"&&(ms.innerHTML=Xt),Bl=M(s),U(Js.$$.fragment,s),Xl=M(s),Us=j(s,"P",{"data-svelte-h":!0}),m(Us)!=="svelte-1y7jnff"&&(Us.innerHTML=vt),vl=M(s),bs=j(s,"P",{"data-svelte-h":!0}),m(bs)!=="svelte-1xi026e"&&(bs.innerHTML=Vt),Vl=M(s),Ts=j(s,"P",{"data-svelte-h":!0}),m(Ts)!=="svelte-tbu9c"&&(Ts.innerHTML=Wt),Wl=M(s),fs=j(s,"P",{"data-svelte-h":!0}),m(fs)!=="svelte-1d9jis2"&&(fs.textContent=zt),zl=M(s),hs=j(s,"P",{"data-svelte-h":!0}),m(hs)!=="svelte-1786w2"&&(hs.innerHTML=Et),El=M(s),ds=j(s,"P",{"data-svelte-h":!0}),m(ds)!=="svelte-1xli505"&&(ds.innerHTML=Ht),Hl=M(s),U(ws.$$.fragment,s),Sl=M(s),gs=j(s,"P",{"data-svelte-h":!0}),m(gs)!=="svelte-58c7jq"&&(gs.innerHTML=St),Yl=M(s),_s=j(s,"P",{"data-svelte-h":!0}),m(_s)!=="svelte-16yej49"&&(_s.innerHTML=Yt),Fl=M(s),U($s.$$.fragment,s),Dl=M(s),ks=j(s,"P",{"data-svelte-h":!0}),m(ks)!=="svelte-1xl7vlo"&&(ks.innerHTML=Ft),ql=M(s),Cs=j(s,"P",{"data-svelte-h":!0}),m(Cs)!=="svelte-1yzpwga"&&(Cs.innerHTML=Dt),Ll=M(s),xs=j(s,"P",{"data-svelte-h":!0}),m(xs)!=="svelte-7yhdfb"&&(xs.innerHTML=qt),Pl=M(s),U(Is.$$.fragment,s),Kl=M(s),Rs=j(s,"P",{"data-svelte-h":!0}),m(Rs)!=="svelte-hz2h68"&&(Rs.textContent=Lt),Ol=M(s),U(Zs.$$.fragment,s),st=M(s),Ns=j(s,"P",{"data-svelte-h":!0}),m(Ns)!=="svelte-xoe8xo"&&(Ns.innerHTML=Pt),lt=M(s),As=j(s,"P",{"data-svelte-h":!0}),m(As)!=="svelte-sz4bn"&&(As.innerHTML=Kt),tt=M(s),Gs=j(s,"P",{"data-svelte-h":!0}),m(Gs)!=="svelte-5ri5dk"&&(Gs.textContent=Ot),et=M(s),U(Qs.$$.fragment,s),nt=M(s),U(Bs.$$.fragment,s),at=M(s),X.l(s),tl=M(s),Xs=j(s,"P",{"data-svelte-h":!0}),m(Xs)!=="svelte-10043jj"&&(Xs.innerHTML=se),pt=M(s),A.l(s),el=M(s),vs=j(s,"P",{"data-svelte-h":!0}),m(vs)!=="svelte-1f78lmo"&&(vs.innerHTML=le),rt=M(s),U(Vs.$$.fragment,s),Mt=M(s),U(Ws.$$.fragment,s),it=M(s),zs=j(s,"P",{"data-svelte-h":!0}),m(zs)!=="svelte-6un5b7"&&(zs.innerHTML=te),ct=M(s),U(Es.$$.fragment,s),ot=M(s),Q.l(s),nl=M(s),U(W.$$.fragment,s),yt=M(s),_&&_.l(s),al=M(s),pl=j(s,"P",{}),fe(pl).forEach(n),this.h()},h(){he(t,"name","hf:doc:metadata"),he(t,"content",qe)},m(s,l){xe(document.head,t),a(s,p,l),a(s,e,l),a(s,i,l),b(d,s,l),a(s,c,l),b(g,s,l),a(s,B,l),Hs[h].m(s,l),a(s,Ks,l),Ss[k].m(s,l),a(s,Os,l),a(s,z,l),a(s,Ml,l),a(s,E,l),a(s,il,l),b(H,s,l),a(s,cl,l),Ys[x].m(s,l),a(s,sl,l),a(s,S,l),a(s,ol,l),a(s,Y,l),a(s,yl,l),b(F,s,l),a(s,ul,l),b(D,s,l),a(s,jl,l),a(s,q,l),a(s,ml,l),a(s,L,l),a(s,Jl,l),a(s,P,l),a(s,Ul,l),b(K,s,l),a(s,bl,l),b(O,s,l),a(s,Tl,l),a(s,ss,l),a(s,fl,l),b(ls,s,l),a(s,hl,l),b(ts,s,l),a(s,dl,l),a(s,es,l),a(s,wl,l),b(v,s,l),a(s,gl,l),b(ns,s,l),a(s,_l,l),Fs[R].m(s,l),a(s,ll,l),a(s,as,l),a(s,$l,l),b(ps,s,l),a(s,kl,l),a(s,rs,l),a(s,Cl,l),b(Ms,s,l),a(s,xl,l),b(is,s,l),a(s,Il,l),a(s,cs,l),a(s,Rl,l),b(V,s,l),a(s,Zl,l),a(s,os,l),a(s,Nl,l),b(ys,s,l),a(s,Al,l),a(s,us,l),a(s,Gl,l),b(js,s,l),a(s,Ql,l),a(s,ms,l),a(s,Bl,l),b(Js,s,l),a(s,Xl,l),a(s,Us,l),a(s,vl,l),a(s,bs,l),a(s,Vl,l),a(s,Ts,l),a(s,Wl,l),a(s,fs,l),a(s,zl,l),a(s,hs,l),a(s,El,l),a(s,ds,l),a(s,Hl,l),b(ws,s,l),a(s,Sl,l),a(s,gs,l),a(s,Yl,l),a(s,_s,l),a(s,Fl,l),b($s,s,l),a(s,Dl,l),a(s,ks,l),a(s,ql,l),a(s,Cs,l),a(s,Ll,l),a(s,xs,l),a(s,Pl,l),b(Is,s,l),a(s,Kl,l),a(s,Rs,l),a(s,Ol,l),b(Zs,s,l),a(s,st,l),a(s,Ns,l),a(s,lt,l),a(s,As,l),a(s,tt,l),a(s,Gs,l),a(s,et,l),b(Qs,s,l),a(s,nt,l),b(Bs,s,l),a(s,at,l),X.m(s,l),a(s,tl,l),a(s,Xs,l),a(s,pt,l),Ds[N].m(s,l),a(s,el,l),a(s,vs,l),a(s,rt,l),b(Vs,s,l),a(s,Mt,l),b(Ws,s,l),a(s,it,l),a(s,zs,l),a(s,ct,l),b(Es,s,l),a(s,ot,l),qs[G].m(s,l),a(s,nl,l),b(W,s,l),a(s,yt,l),_&&_.m(s,l),a(s,al,l),a(s,pl,l),ut=!0},p(s,[l]){const Je={};l&1&&(Je.fw=s[0]),d.$set(Je);let Jt=h;h=ne(s),h!==Jt&&(Ps(),y(Hs[Jt],1,1,()=>{Hs[Jt]=null}),Ls(),$=Hs[h],$||($=Hs[h]=ee[h](s),$.c()),o($,1),$.m(Ks.parentNode,Ks));let Ut=k;k=pe(s),k!==Ut&&(Ps(),y(Ss[Ut],1,1,()=>{Ss[Ut]=null}),Ls(),C=Ss[k],C||(C=Ss[k]=ae[k](s),C.c()),o(C,1),C.m(Os.parentNode,Os));let bt=x;x=Me(s),x!==bt&&(Ps(),y(Ys[bt],1,1,()=>{Ys[bt]=null}),Ls(),I=Ys[x],I||(I=Ys[x]=re[x](s),I.c()),o(I,1),I.m(sl.parentNode,sl));const Ue={};l&2&&(Ue.$$scope={dirty:l,ctx:s}),v.$set(Ue);let Tt=R;R=ce(s),R!==Tt&&(Ps(),y(Fs[Tt],1,1,()=>{Fs[Tt]=null}),Ls(),Z=Fs[R],Z||(Z=Fs[R]=ie[R](s),Z.c()),o(Z,1),Z.m(ll.parentNode,ll));const be={};l&2&&(be.$$scope={dirty:l,ctx:s}),V.$set(be),jt!==(jt=oe(s))&&(X.d(1),X=jt(s),X&&(X.c(),X.m(tl.parentNode,tl)));let ft=N;N=ue(s),N!==ft&&(Ps(),y(Ds[ft],1,1,()=>{Ds[ft]=null}),Ls(),A=Ds[N],A||(A=Ds[N]=ye[N](s),A.c()),o(A,1),A.m(el.parentNode,el));let ht=G;G=me(s),G!==ht&&(Ps(),y(qs[ht],1,1,()=>{qs[ht]=null}),Ls(),Q=qs[G],Q||(Q=qs[G]=je[G](s),Q.c()),o(Q,1),Q.m(nl.parentNode,nl));const Te={};l&2&&(Te.$$scope={dirty:l,ctx:s}),W.$set(Te),s[0]==="tf"?_?l&1&&o(_,1):(_=de(),_.c(),o(_,1),_.m(al.parentNode,al)):_&&(Ps(),y(_,1,1,()=>{_=null}),Ls())},i(s){ut||(o(d.$$.fragment,s),o(g.$$.fragment,s),o($),o(C),o(H.$$.fragment,s),o(I),o(F.$$.fragment,s),o(D.$$.fragment,s),o(K.$$.fragment,s),o(O.$$.fragment,s),o(ls.$$.fragment,s),o(ts.$$.fragment,s),o(v.$$.fragment,s),o(ns.$$.fragment,s),o(Z),o(ps.$$.fragment,s),o(Ms.$$.fragment,s),o(is.$$.fragment,s),o(V.$$.fragment,s),o(ys.$$.fragment,s),o(js.$$.fragment,s),o(Js.$$.fragment,s),o(ws.$$.fragment,s),o($s.$$.fragment,s),o(Is.$$.fragment,s),o(Zs.$$.fragment,s),o(Qs.$$.fragment,s),o(Bs.$$.fragment,s),o(A),o(Vs.$$.fragment,s),o(Ws.$$.fragment,s),o(Es.$$.fragment,s),o(Q),o(W.$$.fragment,s),o(_),ut=!0)},o(s){y(d.$$.fragment,s),y(g.$$.fragment,s),y($),y(C),y(H.$$.fragment,s),y(I),y(F.$$.fragment,s),y(D.$$.fragment,s),y(K.$$.fragment,s),y(O.$$.fragment,s),y(ls.$$.fragment,s),y(ts.$$.fragment,s),y(v.$$.fragment,s),y(ns.$$.fragment,s),y(Z),y(ps.$$.fragment,s),y(Ms.$$.fragment,s),y(is.$$.fragment,s),y(V.$$.fragment,s),y(ys.$$.fragment,s),y(js.$$.fragment,s),y(Js.$$.fragment,s),y(ws.$$.fragment,s),y($s.$$.fragment,s),y(Is.$$.fragment,s),y(Zs.$$.fragment,s),y(Qs.$$.fragment,s),y(Bs.$$.fragment,s),y(A),y(Vs.$$.fragment,s),y(Ws.$$.fragment,s),y(Es.$$.fragment,s),y(Q),y(W.$$.fragment,s),y(_),ut=!1},d(s){s&&(n(p),n(e),n(i),n(c),n(B),n(Ks),n(Os),n(z),n(Ml),n(E),n(il),n(cl),n(sl),n(S),n(ol),n(Y),n(yl),n(ul),n(jl),n(q),n(ml),n(L),n(Jl),n(P),n(Ul),n(bl),n(Tl),n(ss),n(fl),n(hl),n(dl),n(es),n(wl),n(gl),n(_l),n(ll),n(as),n($l),n(kl),n(rs),n(Cl),n(xl),n(Il),n(cs),n(Rl),n(Zl),n(os),n(Nl),n(Al),n(us),n(Gl),n(Ql),n(ms),n(Bl),n(Xl),n(Us),n(vl),n(bs),n(Vl),n(Ts),n(Wl),n(fs),n(zl),n(hs),n(El),n(ds),n(Hl),n(Sl),n(gs),n(Yl),n(_s),n(Fl),n(Dl),n(ks),n(ql),n(Cs),n(Ll),n(xs),n(Pl),n(Kl),n(Rs),n(Ol),n(st),n(Ns),n(lt),n(As),n(tt),n(Gs),n(et),n(nt),n(at),n(tl),n(Xs),n(pt),n(el),n(vs),n(rt),n(Mt),n(it),n(zs),n(ct),n(ot),n(nl),n(yt),n(al),n(pl)),n(t),T(d,s),T(g,s),Hs[h].d(s),Ss[k].d(s),T(H,s),Ys[x].d(s),T(F,s),T(D,s),T(K,s),T(O,s),T(ls,s),T(ts,s),T(v,s),T(ns,s),Fs[R].d(s),T(ps,s),T(Ms,s),T(is,s),T(V,s),T(ys,s),T(js,s),T(Js,s),T(ws,s),T($s,s),T(Is,s),T(Zs,s),T(Qs,s),T(Bs,s),X.d(s),Ds[N].d(s),T(Vs,s),T(Ws,s),T(Es,s),qs[G].d(s),T(W,s),_&&_.d(s)}}}const qe='{"title":"处理数据","local":"处理数据","sections":[{"title":"从模型中心（Hub）加载数据集","local":"从模型中心（Hub）加载数据集","sections":[],"depth":3},{"title":"预处理数据集","local":"预处理数据集","sections":[],"depth":3},{"title":"动态填充","local":"动态填充","sections":[],"depth":3}],"depth":1}';function Le(f,t,p){let e="pt";return _e(()=>{const i=new URLSearchParams(window.location.search);p(0,e=i.get("fw")||"pt")}),[e]}class an extends $e{constructor(t){super(),ke(this,t,Le,De,ge,{})}}export{an as component};
