import{s as gl,o as kl,n as Ut}from"../chunks/scheduler.37c15a92.js";import{S as _l,i as $l,g as d,s as o,r as m,A as Cl,h as u,f as n,c as r,j as wl,u as f,x as y,k as Jl,y as xl,a,v as j,t as M,b as Le,d as h,w as b,p as Pe}from"../chunks/index.2bf4358c.js";import{T as Tt}from"../chunks/Tip.363c041f.js";import{Y as os}from"../chunks/Youtube.1e50a667.js";import{C as U}from"../chunks/CodeBlock.4f5fc1ad.js";import{C as Ul}from"../chunks/CourseFloatingBanner.15ba07e6.js";import{F as Il}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as yt}from"../chunks/Heading.8ada512a.js";function vl(w){let t,i;return t=new Ul({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/en/chapter3/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter3/section2_tf.ipynb"}]}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Rl(w){let t,i;return t=new Ul({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/en/chapter3/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter3/section2_pt.ipynb"}]}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Nl(w){let t,i='Continuing with the example from the <a href="/course/chapter2">previous chapter</a>, here is how we would train a sequence classifier on one batch in TensorFlow:',l,p,T;return p=new U({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=d("p"),t.innerHTML=i,l=o(),m(p.$$.fragment)},l(c){t=u(c,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1bedvbw"&&(t.innerHTML=i),l=r(c),f(p.$$.fragment,c)},m(c,g){a(c,t,g),a(c,l,g),j(p,c,g),T=!0},i(c){T||(h(p.$$.fragment,c),T=!0)},o(c){M(p.$$.fragment,c),T=!1},d(c){c&&(n(t),n(l)),b(p,c)}}}function Zl(w){let t,i='Continuing with the example from the <a href="/course/chapter2">previous chapter</a>, here is how we would train a sequence classifier on one batch in PyTorch:',l,p,T;return p=new U({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=d("p"),t.innerHTML=i,l=o(),m(p.$$.fragment)},l(c){t=u(c,"P",{"data-svelte-h":!0}),y(t)!=="svelte-18ln3r8"&&(t.innerHTML=i),l=r(c),f(p.$$.fragment,c)},m(c,g){a(c,t,g),a(c,l,g),j(p,c,g),T=!0},i(c){T||(h(p.$$.fragment,c),T=!0)},o(c){M(p.$$.fragment,c),T=!1},d(c){c&&(n(t),n(l)),b(p,c)}}}function Al(w){let t,i;return t=new os({props:{id:"W_gMJF0xomE"}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Ql(w){let t,i;return t=new os({props:{id:"_BZearw7f0w"}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Gl(w){let t,i="✏️ <strong>Try it out!</strong> Look at element 15 of the training set and element 87 of the validation set. What are their labels?";return{c(){t=d("p"),t.innerHTML=i},l(l){t=u(l,"P",{"data-svelte-h":!0}),y(t)!=="svelte-vjl0ht"&&(t.innerHTML=i)},m(l,p){a(l,t,p)},p:Ut,d(l){l&&n(t)}}}function Wl(w){let t,i;return t=new os({props:{id:"P-rZWqcB6CE"}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Bl(w){let t,i;return t=new os({props:{id:"0u3ioSwev3s"}}),{c(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Xl(w){let t,i="✏️ <strong>Try it out!</strong> Take element 15 of the training set and tokenize the two sentences separately and as a pair. What’s the difference between the two results?";return{c(){t=d("p"),t.innerHTML=i},l(l){t=u(l,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1j17f76"&&(t.innerHTML=i)},m(l,p){a(l,t,p)},p:Ut,d(l){l&&n(t)}}}function zl(w){let t,i="The function that is responsible for putting together samples inside a batch is called a <em>collate function</em>. The default collator is a function that will just convert your samples to tf.Tensor and concatenate them (recursively if your elements are lists, tuples, or dictionaries). This won’t be possible in our case since the inputs we have won’t all be of the same size. We have deliberately postponed the padding, to only apply it as necessary on each batch and avoid having over-long inputs with a lot of padding. This will speed up training by quite a bit, but note that if you’re training on a TPU it can cause problems — TPUs prefer fixed shapes, even when that requires extra padding.";return{c(){t=d("p"),t.innerHTML=i},l(l){t=u(l,"P",{"data-svelte-h":!0}),y(t)!=="svelte-ect424"&&(t.innerHTML=i)},m(l,p){a(l,t,p)},d(l){l&&n(t)}}}function Vl(w){let t,i="The function that is responsible for putting together samples inside a batch is called a <em>collate function</em>. It’s an argument you can pass when you build a <code>DataLoader</code>, the default being a function that will just convert your samples to PyTorch tensors and concatenate them (recursively if your elements are lists, tuples, or dictionaries). This won’t be possible in our case since the inputs we have won’t all be of the same size. We have deliberately postponed the padding, to only apply it as necessary on each batch and avoid having over-long inputs with a lot of padding. This will speed up training by quite a bit, but note that if you’re training on a TPU it can cause problems — TPUs prefer fixed shapes, even when that requires extra padding.";return{c(){t=d("p"),t.innerHTML=i},l(l){t=u(l,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1gicira"&&(t.innerHTML=i)},m(l,p){a(l,t,p)},d(l){l&&n(t)}}}function El(w){let t,i;return t=new U({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(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Hl(w){let t,i;return t=new U({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(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Sl(w){let t,i,l,p="Looking good! Now that we’ve gone from raw text to batches our model can deal with, we’re ready to fine-tune it!",T;return t=new U({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(){m(t.$$.fragment),i=o(),l=d("p"),l.textContent=p},l(c){f(t.$$.fragment,c),i=r(c),l=u(c,"P",{"data-svelte-h":!0}),y(l)!=="svelte-3l70up"&&(l.textContent=p)},m(c,g){j(t,c,g),a(c,i,g),a(c,l,g),T=!0},i(c){T||(h(t.$$.fragment,c),T=!0)},o(c){M(t.$$.fragment,c),T=!1},d(c){c&&(n(i),n(l)),b(t,c)}}}function Yl(w){let t,i;return t=new U({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(){m(t.$$.fragment)},l(l){f(t.$$.fragment,l)},m(l,p){j(t,l,p),i=!0},i(l){i||(h(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Fl(w){let t,i="✏️ <strong>Try it out!</strong> Replicate the preprocessing on the GLUE SST-2 dataset. It’s a little bit different since it’s composed of single sentences instead of pairs, but the rest of what we did should look the same. For a harder challenge, try to write a preprocessing function that works on any of the GLUE tasks.";return{c(){t=d("p"),t.innerHTML=i},l(l){t=u(l,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1ydnchh"&&(t.innerHTML=i)},m(l,p){a(l,t,p)},p:Ut,d(l){l&&n(t)}}}function Tl(w){let t,i="Now that we have our dataset and a data collator, we need to put them together. We could manually load batches and collate them, but that’s a lot of work, and probably not very performant either. Instead, there’s a simple method that offers a performant solution to this problem: <code>to_tf_dataset()</code>. This will wrap a <code>tf.data.Dataset</code> around your dataset, with an optional collation function. <code>tf.data.Dataset</code> is a native TensorFlow format that Keras can use for <code>model.fit()</code>, so this one method immediately converts a 🤗 Dataset to a format that’s ready for training. Let’s see it in action with our dataset!",l,p,T,c,g="And that’s it! We can take those datasets forward into the next lecture, where training will be pleasantly straightforward after all the hard work of data preprocessing.",G;return p=new U({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=d("p"),t.innerHTML=i,l=o(),m(p.$$.fragment),T=o(),c=d("p"),c.textContent=g},l(J){t=u(J,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1ep2ytl"&&(t.innerHTML=i),l=r(J),f(p.$$.fragment,J),T=r(J),c=u(J,"P",{"data-svelte-h":!0}),y(c)!=="svelte-2qcqqp"&&(c.textContent=g)},m(J,_){a(J,t,_),a(J,l,_),j(p,J,_),a(J,T,_),a(J,c,_),G=!0},i(J){G||(h(p.$$.fragment,J),G=!0)},o(J){M(p.$$.fragment,J),G=!1},d(J){J&&(n(t),n(l),n(T),n(c)),b(p,J)}}}function Dl(w){let t,i,l,p,T,c,g,G,J,_,Ke,$,C,Oe,V,gt="Of course, just training the model on two sentences is not going to yield very good results. To get better results, you will need to prepare a bigger dataset.",rs,E,kt='In this section we will use as an example the MRPC (Microsoft Research Paraphrase Corpus) dataset, introduced in a <a href="https://www.aclweb.org/anthology/I05-5002.pdf" rel="nofollow">paper</a> by William B. Dolan and Chris Brockett. The dataset consists of 5,801 pairs of sentences, with a label indicating if they are paraphrases or not (i.e., if both sentences mean the same thing). We’ve selected it for this chapter because it’s a small dataset, so it’s easy to experiment with training on it.',ps,H,cs,x,I,es,S,_t='The Hub doesn’t just contain models; it also has multiple datasets in lots of different languages. You can browse the datasets <a href="https://huggingface.co/datasets" rel="nofollow">here</a>, and we recommend you try to load and process a new dataset once you have gone through this section (see the general documentation <a href="https://huggingface.co/docs/datasets/loading" rel="nofollow">here</a>). But for now, let’s focus on the MRPC dataset! This is one of the 10 datasets composing the <a href="https://gluebenchmark.com/" rel="nofollow">GLUE benchmark</a>, which is an academic benchmark that is used to measure the performance of ML models across 10 different text classification tasks.',hs,Y,$t="The 🤗 Datasets library provides a very simple command to download and cache a dataset on the Hub. We can download the MRPC dataset like this:",Ms,F,ds,D,us,q,Ct="As you can see, we get a <code>DatasetDict</code> object which contains the training set, the validation set, and the test set. Each of those contains several columns (<code>sentence1</code>, <code>sentence2</code>, <code>label</code>, and <code>idx</code>) and a variable number of rows, which are the number of elements in each set (so, there are 3,668 pairs of sentences in the training set, 408 in the validation set, and 1,725 in the test set).",ys,L,xt="This command downloads and caches the dataset, by default in <em>~/.cache/huggingface/datasets</em>. Recall from Chapter 2 that you can customize your cache folder by setting the <code>HF_HOME</code> environment variable.",ms,P,It="We can access each pair of sentences in our <code>raw_datasets</code> object by indexing, like with a dictionary:",fs,K,js,O,bs,ee,vt="We can see the labels are already integers, so we won’t have to do any preprocessing there. To know which integer corresponds to which label, we can inspect the <code>features</code> of our <code>raw_train_dataset</code>. This will tell us the type of each column:",ws,se,Js,te,Ts,le,Rt="Behind the scenes, <code>label</code> is of type <code>ClassLabel</code>, and the mapping of integers to label name is stored in the <em>names</em> folder. <code>0</code> corresponds to <code>not_equivalent</code>, and <code>1</code> corresponds to <code>equivalent</code>.",Us,B,gs,ne,ks,v,R,ss,ae,Nt='To preprocess the dataset, we need to convert the text to numbers the model can make sense of. As you saw in the <a href="/course/chapter2">previous chapter</a>, this is done with a tokenizer. We can feed the tokenizer one sentence or a list of sentences, so we can directly tokenize all the first sentences and all the second sentences of each pair like this:',_s,ie,$s,oe,Zt="However, we can’t just pass two sequences to the model and get a prediction of whether the two sentences are paraphrases or not. We need to handle the two sequences as a pair, and apply the appropriate preprocessing. Fortunately, the tokenizer can also take a pair of sequences and prepare it the way our BERT model expects:",Cs,re,xs,pe,Is,ce,At='We discussed the <code>input_ids</code> and <code>attention_mask</code> keys in <a href="/course/chapter2">Chapter 2</a>, but we put off talking about <code>token_type_ids</code>. In this example, this is what tells the model which part of the input is the first sentence and which is the second sentence.',vs,X,Rs,he,Qt="If we decode the IDs inside <code>input_ids</code> back to words:",Ns,Me,Zs,de,Gt="we will get:",As,ue,Qs,ye,Wt="So we see the model expects the inputs to be of the form <code>[CLS] sentence1 [SEP] sentence2 [SEP]</code> when there are two sentences. Aligning this with the <code>token_type_ids</code> gives us:",Gs,me,Ws,fe,Bt="As you can see, the parts of the input corresponding to <code>[CLS] sentence1 [SEP]</code> all have a token type ID of <code>0</code>, while the other parts, corresponding to <code>sentence2 [SEP]</code>, all have a token type ID of <code>1</code>.",Bs,je,Xt="Note that if you select a different checkpoint, you won’t necessarily have the <code>token_type_ids</code> in your tokenized inputs (for instance, they’re not returned if you use a DistilBERT model). They are only returned when the model will know what to do with them, because it has seen them during its pretraining.",Xs,be,zt='Here, BERT is pretrained with token type IDs, and on top of the masked language modeling objective we talked about in <a href="/course/chapter1">Chapter 1</a>, it has an additional objective called <em>next sentence prediction</em>. The goal with this task is to model the relationship between pairs of sentences.',zs,we,Vt="With next sentence prediction, the model is provided pairs of sentences (with randomly masked tokens) and asked to predict whether the second sentence follows the first. To make the task non-trivial, half of the time the sentences follow each other in the original document they were extracted from, and the other half of the time the two sentences come from two different documents.",Vs,Je,Et="In general, you don’t need to worry about whether or not there are <code>token_type_ids</code> in your tokenized inputs: as long as you use the same checkpoint for the tokenizer and the model, everything will be fine as the tokenizer knows what to provide to its model.",Es,Te,Ht='Now that we have seen how our tokenizer can deal with one pair of sentences, we can use it to tokenize our whole dataset: like in the <a href="/course/chapter2">previous chapter</a>, we can feed the tokenizer a list of pairs of sentences by giving it the list of first sentences, then the list of second sentences. This is also compatible with the padding and truncation options we saw in <a href="/course/chapter2">Chapter 2</a>. So, one way to preprocess the training dataset is:',Hs,Ue,Ss,ge,St='This works well, but it has the disadvantage of returning a dictionary (with our keys, <code>input_ids</code>, <code>attention_mask</code>, and <code>token_type_ids</code>, and values that are lists of lists). It will also only work if you have enough RAM to store your whole dataset during the tokenization (whereas the datasets from the 🤗 Datasets library are <a href="https://arrow.apache.org/" rel="nofollow">Apache Arrow</a> files stored on the disk, so you only keep the samples you ask for loaded in memory).',Ys,ke,Yt='To keep the data as a dataset, we will use the <a href="https://huggingface.co/docs/datasets/package_reference/main_classes#datasets.Dataset.map" rel="nofollow"><code>Dataset.map()</code></a> method. This also allows us some extra flexibility, if we need more preprocessing done than just tokenization. The <code>map()</code> method works by applying a function on each element of the dataset, so let’s define a function that tokenizes our inputs:',Fs,_e,Ds,$e,Ft='This function takes a dictionary (like the items of our dataset) and returns a new dictionary with the keys <code>input_ids</code>, <code>attention_mask</code>, and <code>token_type_ids</code>. Note that it also works if the <code>example</code> dictionary contains several samples (each key as a list of sentences) since the <code>tokenizer</code> works on lists of pairs of sentences, as seen before. This will allow us to use the option <code>batched=True</code> in our call to <code>map()</code>, which will greatly speed up the tokenization. The <code>tokenizer</code> is backed by a tokenizer written in Rust from the <a href="https://github.com/huggingface/tokenizers" rel="nofollow">🤗 Tokenizers</a> library. This tokenizer can be very fast, but only if we give it lots of inputs at once.',qs,Ce,Dt="Note that we’ve left the <code>padding</code> argument out in our tokenization function for now. This is because padding all the samples to the maximum length is not efficient: it’s better to pad the samples when we’re building a batch, as then we only need to pad to the maximum length in that batch, and not the maximum length in the entire dataset. This can save a lot of time and processing power when the inputs have very variable lengths!",Ls,xe,qt="Here is how we apply the tokenization function on all our datasets at once. We’re using <code>batched=True</code> in our call to <code>map</code> so the function is applied to multiple elements of our dataset at once, and not on each element separately. This allows for faster preprocessing.",Ps,Ie,Ks,ve,Lt="The way the 🤗 Datasets library applies this processing is by adding new fields to the datasets, one for each key in the dictionary returned by the preprocessing function:",Os,Re,et,Ne,Pt="You can even use multiprocessing when applying your preprocessing function with <code>map()</code> by passing along a <code>num_proc</code> argument. We didn’t do this here because the 🤗 Tokenizers library already uses multiple threads to tokenize our samples faster, but if you are not using a fast tokenizer backed by this library, this could speed up your preprocessing.",st,Ze,Kt="Our <code>tokenize_function</code> returns a dictionary with the keys <code>input_ids</code>, <code>attention_mask</code>, and <code>token_type_ids</code>, so those three fields are added to all splits of our dataset. Note that we could also have changed existing fields if our preprocessing function returned a new value for an existing key in the dataset to which we applied <code>map()</code>.",tt,Ae,Ot="The last thing we will need to do is pad all the examples to the length of the longest element when we batch elements together — a technique we refer to as <em>dynamic padding</em>.",lt,Qe,nt,Ge,at,ts,We,el="To do this in practice, we have to define a collate function that will apply the correct amount of padding to the items of the dataset we want to batch together. Fortunately, the 🤗 Transformers library provides us with such a function via <code>DataCollatorWithPadding</code>. It takes a tokenizer when you instantiate it (to know which padding token to use, and whether the model expects padding to be on the left or on the right of the inputs) and will do everything you need:",it,N,Z,ls,Be,sl="To test this new toy, let’s grab a few samples from our training set that we would like to batch together. Here, we remove the columns <code>idx</code>, <code>sentence1</code>, and <code>sentence2</code> as they won’t be needed and contain strings (and we can’t create tensors with strings) and have a look at the lengths of each entry in the batch:",ot,Xe,rt,ze,pt,Ve,tl="No surprise, we get samples of varying length, from 32 to 67. Dynamic padding means the samples in this batch should all be padded to a length of 67, the maximum length inside the batch. Without dynamic padding, all of the samples would have to be padded to the maximum length in the whole dataset, or the maximum length the model can accept. Let’s double-check that our <code>data_collator</code> is dynamically padding the batch properly:",ct,Ee,ht,A,Q,ns,z,Mt,as,is,dt;T=new Il({props:{fw:w[0]}}),g=new yt({props:{title:"Processing the data",local:"processing-the-data",headingTag:"h1"}});const ll=[Rl,vl],He=[];function nl(e,s){return e[0]==="pt"?0:1}J=nl(w),_=He[J]=ll[J](w);const al=[Zl,Nl],Se=[];function il(e,s){return e[0]==="pt"?0:1}$=il(w),C=Se[$]=al[$](w),H=new yt({props:{title:"Loading a dataset from the Hub",local:"loading-a-dataset-from-the-hub",headingTag:"h3"}});const ol=[Ql,Al],Ye=[];function rl(e,s){return e[0]==="pt"?0:1}x=rl(w),I=Ye[x]=ol[x](w),F=new U({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 U({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 U({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 U({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}}),se=new U({props:{code:"cmF3X3RyYWluX2RhdGFzZXQuZmVhdHVyZXM=",highlighted:"raw_train_dataset.features",wrap:!1}}),te=new U({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}}),B=new Tt({props:{$$slots:{default:[Gl]},$$scope:{ctx:w}}}),ne=new yt({props:{title:"Preprocessing a dataset",local:"preprocessing-a-dataset",headingTag:"h3"}});const pl=[Bl,Wl],Fe=[];function cl(e,s){return e[0]==="pt"?0:1}v=cl(w),R=Fe[v]=pl[v](w),ie=new U({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}}),re=new U({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}}),pe=new U({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}}),X=new Tt({props:{$$slots:{default:[Xl]},$$scope:{ctx:w}}}),Me=new U({props:{code:"dG9rZW5pemVyLmNvbnZlcnRfaWRzX3RvX3Rva2VucyhpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQp",highlighted:'tokenizer.convert_ids_to_tokens(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])',wrap:!1}}),ue=new U({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}}),me=new U({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}}),Ue=new U({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}}),_e=new U({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}}),Ie=new U({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}}),Re=new U({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}}),Qe=new yt({props:{title:"Dynamic padding",local:"dynamic-padding",headingTag:"h3"}}),Ge=new os({props:{id:"7q5NyFT8REg"}});function hl(e,s){return e[0]==="pt"?Vl:zl}let ut=hl(w),W=ut(w);const Ml=[Hl,El],De=[];function dl(e,s){return e[0]==="pt"?0:1}N=dl(w),Z=De[N]=Ml[N](w),Xe=new U({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}}),ze=new U({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}}),Ee=new U({props:{code:"YmF0Y2glMjAlM0QlMjBkYXRhX2NvbGxhdG9yKHNhbXBsZXMpJTBBJTdCayUzQSUyMHYuc2hhcGUlMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwYmF0Y2guaXRlbXMoKSU3RA==",highlighted:`batch = data_collator(samples)
{k: v.shape <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}`,wrap:!1}});const ul=[Yl,Sl],qe=[];function yl(e,s){return e[0]==="tf"?0:1}A=yl(w),Q=qe[A]=ul[A](w),z=new Tt({props:{$$slots:{default:[Fl]},$$scope:{ctx:w}}});let k=w[0]==="tf"&&Tl();return{c(){t=d("meta"),i=o(),l=d("p"),p=o(),m(T.$$.fragment),c=o(),m(g.$$.fragment),G=o(),_.c(),Ke=o(),C.c(),Oe=o(),V=d("p"),V.textContent=gt,rs=o(),E=d("p"),E.innerHTML=kt,ps=o(),m(H.$$.fragment),cs=o(),I.c(),es=o(),S=d("p"),S.innerHTML=_t,hs=o(),Y=d("p"),Y.textContent=$t,Ms=o(),m(F.$$.fragment),ds=o(),m(D.$$.fragment),us=o(),q=d("p"),q.innerHTML=Ct,ys=o(),L=d("p"),L.innerHTML=xt,ms=o(),P=d("p"),P.innerHTML=It,fs=o(),m(K.$$.fragment),js=o(),m(O.$$.fragment),bs=o(),ee=d("p"),ee.innerHTML=vt,ws=o(),m(se.$$.fragment),Js=o(),m(te.$$.fragment),Ts=o(),le=d("p"),le.innerHTML=Rt,Us=o(),m(B.$$.fragment),gs=o(),m(ne.$$.fragment),ks=o(),R.c(),ss=o(),ae=d("p"),ae.innerHTML=Nt,_s=o(),m(ie.$$.fragment),$s=o(),oe=d("p"),oe.textContent=Zt,Cs=o(),m(re.$$.fragment),xs=o(),m(pe.$$.fragment),Is=o(),ce=d("p"),ce.innerHTML=At,vs=o(),m(X.$$.fragment),Rs=o(),he=d("p"),he.innerHTML=Qt,Ns=o(),m(Me.$$.fragment),Zs=o(),de=d("p"),de.textContent=Gt,As=o(),m(ue.$$.fragment),Qs=o(),ye=d("p"),ye.innerHTML=Wt,Gs=o(),m(me.$$.fragment),Ws=o(),fe=d("p"),fe.innerHTML=Bt,Bs=o(),je=d("p"),je.innerHTML=Xt,Xs=o(),be=d("p"),be.innerHTML=zt,zs=o(),we=d("p"),we.textContent=Vt,Vs=o(),Je=d("p"),Je.innerHTML=Et,Es=o(),Te=d("p"),Te.innerHTML=Ht,Hs=o(),m(Ue.$$.fragment),Ss=o(),ge=d("p"),ge.innerHTML=St,Ys=o(),ke=d("p"),ke.innerHTML=Yt,Fs=o(),m(_e.$$.fragment),Ds=o(),$e=d("p"),$e.innerHTML=Ft,qs=o(),Ce=d("p"),Ce.innerHTML=Dt,Ls=o(),xe=d("p"),xe.innerHTML=qt,Ps=o(),m(Ie.$$.fragment),Ks=o(),ve=d("p"),ve.textContent=Lt,Os=o(),m(Re.$$.fragment),et=o(),Ne=d("p"),Ne.innerHTML=Pt,st=o(),Ze=d("p"),Ze.innerHTML=Kt,tt=o(),Ae=d("p"),Ae.innerHTML=Ot,lt=o(),m(Qe.$$.fragment),nt=o(),m(Ge.$$.fragment),at=o(),W.c(),ts=o(),We=d("p"),We.innerHTML=el,it=o(),Z.c(),ls=o(),Be=d("p"),Be.innerHTML=sl,ot=o(),m(Xe.$$.fragment),rt=o(),m(ze.$$.fragment),pt=o(),Ve=d("p"),Ve.innerHTML=tl,ct=o(),m(Ee.$$.fragment),ht=o(),Q.c(),ns=o(),m(z.$$.fragment),Mt=o(),k&&k.c(),as=o(),is=d("p"),this.h()},l(e){const s=Cl("svelte-u9bgzb",document.head);t=u(s,"META",{name:!0,content:!0}),s.forEach(n),i=r(e),l=u(e,"P",{}),wl(l).forEach(n),p=r(e),f(T.$$.fragment,e),c=r(e),f(g.$$.fragment,e),G=r(e),_.l(e),Ke=r(e),C.l(e),Oe=r(e),V=u(e,"P",{"data-svelte-h":!0}),y(V)!=="svelte-k42f7q"&&(V.textContent=gt),rs=r(e),E=u(e,"P",{"data-svelte-h":!0}),y(E)!=="svelte-zjffq0"&&(E.innerHTML=kt),ps=r(e),f(H.$$.fragment,e),cs=r(e),I.l(e),es=r(e),S=u(e,"P",{"data-svelte-h":!0}),y(S)!=="svelte-1l7s9ct"&&(S.innerHTML=_t),hs=r(e),Y=u(e,"P",{"data-svelte-h":!0}),y(Y)!=="svelte-a0uedu"&&(Y.textContent=$t),Ms=r(e),f(F.$$.fragment,e),ds=r(e),f(D.$$.fragment,e),us=r(e),q=u(e,"P",{"data-svelte-h":!0}),y(q)!=="svelte-1c0bj8y"&&(q.innerHTML=Ct),ys=r(e),L=u(e,"P",{"data-svelte-h":!0}),y(L)!=="svelte-124lsw3"&&(L.innerHTML=xt),ms=r(e),P=u(e,"P",{"data-svelte-h":!0}),y(P)!=="svelte-65xqw4"&&(P.innerHTML=It),fs=r(e),f(K.$$.fragment,e),js=r(e),f(O.$$.fragment,e),bs=r(e),ee=u(e,"P",{"data-svelte-h":!0}),y(ee)!=="svelte-1o36uf9"&&(ee.innerHTML=vt),ws=r(e),f(se.$$.fragment,e),Js=r(e),f(te.$$.fragment,e),Ts=r(e),le=u(e,"P",{"data-svelte-h":!0}),y(le)!=="svelte-1c3slq1"&&(le.innerHTML=Rt),Us=r(e),f(B.$$.fragment,e),gs=r(e),f(ne.$$.fragment,e),ks=r(e),R.l(e),ss=r(e),ae=u(e,"P",{"data-svelte-h":!0}),y(ae)!=="svelte-cvke6e"&&(ae.innerHTML=Nt),_s=r(e),f(ie.$$.fragment,e),$s=r(e),oe=u(e,"P",{"data-svelte-h":!0}),y(oe)!=="svelte-17gxq0h"&&(oe.textContent=Zt),Cs=r(e),f(re.$$.fragment,e),xs=r(e),f(pe.$$.fragment,e),Is=r(e),ce=u(e,"P",{"data-svelte-h":!0}),y(ce)!=="svelte-s9c1sv"&&(ce.innerHTML=At),vs=r(e),f(X.$$.fragment,e),Rs=r(e),he=u(e,"P",{"data-svelte-h":!0}),y(he)!=="svelte-17ajvt1"&&(he.innerHTML=Qt),Ns=r(e),f(Me.$$.fragment,e),Zs=r(e),de=u(e,"P",{"data-svelte-h":!0}),y(de)!=="svelte-1oivwa"&&(de.textContent=Gt),As=r(e),f(ue.$$.fragment,e),Qs=r(e),ye=u(e,"P",{"data-svelte-h":!0}),y(ye)!=="svelte-1tvepx7"&&(ye.innerHTML=Wt),Gs=r(e),f(me.$$.fragment,e),Ws=r(e),fe=u(e,"P",{"data-svelte-h":!0}),y(fe)!=="svelte-10hqnfn"&&(fe.innerHTML=Bt),Bs=r(e),je=u(e,"P",{"data-svelte-h":!0}),y(je)!=="svelte-hspdt8"&&(je.innerHTML=Xt),Xs=r(e),be=u(e,"P",{"data-svelte-h":!0}),y(be)!=="svelte-11u1x7y"&&(be.innerHTML=zt),zs=r(e),we=u(e,"P",{"data-svelte-h":!0}),y(we)!=="svelte-1e7se1j"&&(we.textContent=Vt),Vs=r(e),Je=u(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-1ujm1f5"&&(Je.innerHTML=Et),Es=r(e),Te=u(e,"P",{"data-svelte-h":!0}),y(Te)!=="svelte-57wndc"&&(Te.innerHTML=Ht),Hs=r(e),f(Ue.$$.fragment,e),Ss=r(e),ge=u(e,"P",{"data-svelte-h":!0}),y(ge)!=="svelte-12m6ruz"&&(ge.innerHTML=St),Ys=r(e),ke=u(e,"P",{"data-svelte-h":!0}),y(ke)!=="svelte-ykgx4y"&&(ke.innerHTML=Yt),Fs=r(e),f(_e.$$.fragment,e),Ds=r(e),$e=u(e,"P",{"data-svelte-h":!0}),y($e)!=="svelte-1jfj8zf"&&($e.innerHTML=Ft),qs=r(e),Ce=u(e,"P",{"data-svelte-h":!0}),y(Ce)!=="svelte-ko1qsu"&&(Ce.innerHTML=Dt),Ls=r(e),xe=u(e,"P",{"data-svelte-h":!0}),y(xe)!=="svelte-oo95cw"&&(xe.innerHTML=qt),Ps=r(e),f(Ie.$$.fragment,e),Ks=r(e),ve=u(e,"P",{"data-svelte-h":!0}),y(ve)!=="svelte-12x3mv1"&&(ve.textContent=Lt),Os=r(e),f(Re.$$.fragment,e),et=r(e),Ne=u(e,"P",{"data-svelte-h":!0}),y(Ne)!=="svelte-b2zdkp"&&(Ne.innerHTML=Pt),st=r(e),Ze=u(e,"P",{"data-svelte-h":!0}),y(Ze)!=="svelte-k426ib"&&(Ze.innerHTML=Kt),tt=r(e),Ae=u(e,"P",{"data-svelte-h":!0}),y(Ae)!=="svelte-1onxd79"&&(Ae.innerHTML=Ot),lt=r(e),f(Qe.$$.fragment,e),nt=r(e),f(Ge.$$.fragment,e),at=r(e),W.l(e),ts=r(e),We=u(e,"P",{"data-svelte-h":!0}),y(We)!=="svelte-1b915t7"&&(We.innerHTML=el),it=r(e),Z.l(e),ls=r(e),Be=u(e,"P",{"data-svelte-h":!0}),y(Be)!=="svelte-1dw0kzt"&&(Be.innerHTML=sl),ot=r(e),f(Xe.$$.fragment,e),rt=r(e),f(ze.$$.fragment,e),pt=r(e),Ve=u(e,"P",{"data-svelte-h":!0}),y(Ve)!=="svelte-1g0r85d"&&(Ve.innerHTML=tl),ct=r(e),f(Ee.$$.fragment,e),ht=r(e),Q.l(e),ns=r(e),f(z.$$.fragment,e),Mt=r(e),k&&k.l(e),as=r(e),is=u(e,"P",{}),wl(is).forEach(n),this.h()},h(){Jl(t,"name","hf:doc:metadata"),Jl(t,"content",ql)},m(e,s){xl(document.head,t),a(e,i,s),a(e,l,s),a(e,p,s),j(T,e,s),a(e,c,s),j(g,e,s),a(e,G,s),He[J].m(e,s),a(e,Ke,s),Se[$].m(e,s),a(e,Oe,s),a(e,V,s),a(e,rs,s),a(e,E,s),a(e,ps,s),j(H,e,s),a(e,cs,s),Ye[x].m(e,s),a(e,es,s),a(e,S,s),a(e,hs,s),a(e,Y,s),a(e,Ms,s),j(F,e,s),a(e,ds,s),j(D,e,s),a(e,us,s),a(e,q,s),a(e,ys,s),a(e,L,s),a(e,ms,s),a(e,P,s),a(e,fs,s),j(K,e,s),a(e,js,s),j(O,e,s),a(e,bs,s),a(e,ee,s),a(e,ws,s),j(se,e,s),a(e,Js,s),j(te,e,s),a(e,Ts,s),a(e,le,s),a(e,Us,s),j(B,e,s),a(e,gs,s),j(ne,e,s),a(e,ks,s),Fe[v].m(e,s),a(e,ss,s),a(e,ae,s),a(e,_s,s),j(ie,e,s),a(e,$s,s),a(e,oe,s),a(e,Cs,s),j(re,e,s),a(e,xs,s),j(pe,e,s),a(e,Is,s),a(e,ce,s),a(e,vs,s),j(X,e,s),a(e,Rs,s),a(e,he,s),a(e,Ns,s),j(Me,e,s),a(e,Zs,s),a(e,de,s),a(e,As,s),j(ue,e,s),a(e,Qs,s),a(e,ye,s),a(e,Gs,s),j(me,e,s),a(e,Ws,s),a(e,fe,s),a(e,Bs,s),a(e,je,s),a(e,Xs,s),a(e,be,s),a(e,zs,s),a(e,we,s),a(e,Vs,s),a(e,Je,s),a(e,Es,s),a(e,Te,s),a(e,Hs,s),j(Ue,e,s),a(e,Ss,s),a(e,ge,s),a(e,Ys,s),a(e,ke,s),a(e,Fs,s),j(_e,e,s),a(e,Ds,s),a(e,$e,s),a(e,qs,s),a(e,Ce,s),a(e,Ls,s),a(e,xe,s),a(e,Ps,s),j(Ie,e,s),a(e,Ks,s),a(e,ve,s),a(e,Os,s),j(Re,e,s),a(e,et,s),a(e,Ne,s),a(e,st,s),a(e,Ze,s),a(e,tt,s),a(e,Ae,s),a(e,lt,s),j(Qe,e,s),a(e,nt,s),j(Ge,e,s),a(e,at,s),W.m(e,s),a(e,ts,s),a(e,We,s),a(e,it,s),De[N].m(e,s),a(e,ls,s),a(e,Be,s),a(e,ot,s),j(Xe,e,s),a(e,rt,s),j(ze,e,s),a(e,pt,s),a(e,Ve,s),a(e,ct,s),j(Ee,e,s),a(e,ht,s),qe[A].m(e,s),a(e,ns,s),j(z,e,s),a(e,Mt,s),k&&k.m(e,s),a(e,as,s),a(e,is,s),dt=!0},p(e,[s]){const ml={};s&1&&(ml.fw=e[0]),T.$set(ml);let mt=J;J=nl(e),J!==mt&&(Pe(),M(He[mt],1,1,()=>{He[mt]=null}),Le(),_=He[J],_||(_=He[J]=ll[J](e),_.c()),h(_,1),_.m(Ke.parentNode,Ke));let ft=$;$=il(e),$!==ft&&(Pe(),M(Se[ft],1,1,()=>{Se[ft]=null}),Le(),C=Se[$],C||(C=Se[$]=al[$](e),C.c()),h(C,1),C.m(Oe.parentNode,Oe));let jt=x;x=rl(e),x!==jt&&(Pe(),M(Ye[jt],1,1,()=>{Ye[jt]=null}),Le(),I=Ye[x],I||(I=Ye[x]=ol[x](e),I.c()),h(I,1),I.m(es.parentNode,es));const fl={};s&2&&(fl.$$scope={dirty:s,ctx:e}),B.$set(fl);let bt=v;v=cl(e),v!==bt&&(Pe(),M(Fe[bt],1,1,()=>{Fe[bt]=null}),Le(),R=Fe[v],R||(R=Fe[v]=pl[v](e),R.c()),h(R,1),R.m(ss.parentNode,ss));const jl={};s&2&&(jl.$$scope={dirty:s,ctx:e}),X.$set(jl),ut!==(ut=hl(e))&&(W.d(1),W=ut(e),W&&(W.c(),W.m(ts.parentNode,ts)));let wt=N;N=dl(e),N!==wt&&(Pe(),M(De[wt],1,1,()=>{De[wt]=null}),Le(),Z=De[N],Z||(Z=De[N]=Ml[N](e),Z.c()),h(Z,1),Z.m(ls.parentNode,ls));let Jt=A;A=yl(e),A!==Jt&&(Pe(),M(qe[Jt],1,1,()=>{qe[Jt]=null}),Le(),Q=qe[A],Q||(Q=qe[A]=ul[A](e),Q.c()),h(Q,1),Q.m(ns.parentNode,ns));const bl={};s&2&&(bl.$$scope={dirty:s,ctx:e}),z.$set(bl),e[0]==="tf"?k?s&1&&h(k,1):(k=Tl(),k.c(),h(k,1),k.m(as.parentNode,as)):k&&(Pe(),M(k,1,1,()=>{k=null}),Le())},i(e){dt||(h(T.$$.fragment,e),h(g.$$.fragment,e),h(_),h(C),h(H.$$.fragment,e),h(I),h(F.$$.fragment,e),h(D.$$.fragment,e),h(K.$$.fragment,e),h(O.$$.fragment,e),h(se.$$.fragment,e),h(te.$$.fragment,e),h(B.$$.fragment,e),h(ne.$$.fragment,e),h(R),h(ie.$$.fragment,e),h(re.$$.fragment,e),h(pe.$$.fragment,e),h(X.$$.fragment,e),h(Me.$$.fragment,e),h(ue.$$.fragment,e),h(me.$$.fragment,e),h(Ue.$$.fragment,e),h(_e.$$.fragment,e),h(Ie.$$.fragment,e),h(Re.$$.fragment,e),h(Qe.$$.fragment,e),h(Ge.$$.fragment,e),h(Z),h(Xe.$$.fragment,e),h(ze.$$.fragment,e),h(Ee.$$.fragment,e),h(Q),h(z.$$.fragment,e),h(k),dt=!0)},o(e){M(T.$$.fragment,e),M(g.$$.fragment,e),M(_),M(C),M(H.$$.fragment,e),M(I),M(F.$$.fragment,e),M(D.$$.fragment,e),M(K.$$.fragment,e),M(O.$$.fragment,e),M(se.$$.fragment,e),M(te.$$.fragment,e),M(B.$$.fragment,e),M(ne.$$.fragment,e),M(R),M(ie.$$.fragment,e),M(re.$$.fragment,e),M(pe.$$.fragment,e),M(X.$$.fragment,e),M(Me.$$.fragment,e),M(ue.$$.fragment,e),M(me.$$.fragment,e),M(Ue.$$.fragment,e),M(_e.$$.fragment,e),M(Ie.$$.fragment,e),M(Re.$$.fragment,e),M(Qe.$$.fragment,e),M(Ge.$$.fragment,e),M(Z),M(Xe.$$.fragment,e),M(ze.$$.fragment,e),M(Ee.$$.fragment,e),M(Q),M(z.$$.fragment,e),M(k),dt=!1},d(e){e&&(n(i),n(l),n(p),n(c),n(G),n(Ke),n(Oe),n(V),n(rs),n(E),n(ps),n(cs),n(es),n(S),n(hs),n(Y),n(Ms),n(ds),n(us),n(q),n(ys),n(L),n(ms),n(P),n(fs),n(js),n(bs),n(ee),n(ws),n(Js),n(Ts),n(le),n(Us),n(gs),n(ks),n(ss),n(ae),n(_s),n($s),n(oe),n(Cs),n(xs),n(Is),n(ce),n(vs),n(Rs),n(he),n(Ns),n(Zs),n(de),n(As),n(Qs),n(ye),n(Gs),n(Ws),n(fe),n(Bs),n(je),n(Xs),n(be),n(zs),n(we),n(Vs),n(Je),n(Es),n(Te),n(Hs),n(Ss),n(ge),n(Ys),n(ke),n(Fs),n(Ds),n($e),n(qs),n(Ce),n(Ls),n(xe),n(Ps),n(Ks),n(ve),n(Os),n(et),n(Ne),n(st),n(Ze),n(tt),n(Ae),n(lt),n(nt),n(at),n(ts),n(We),n(it),n(ls),n(Be),n(ot),n(rt),n(pt),n(Ve),n(ct),n(ht),n(ns),n(Mt),n(as),n(is)),n(t),b(T,e),b(g,e),He[J].d(e),Se[$].d(e),b(H,e),Ye[x].d(e),b(F,e),b(D,e),b(K,e),b(O,e),b(se,e),b(te,e),b(B,e),b(ne,e),Fe[v].d(e),b(ie,e),b(re,e),b(pe,e),b(X,e),b(Me,e),b(ue,e),b(me,e),b(Ue,e),b(_e,e),b(Ie,e),b(Re,e),b(Qe,e),b(Ge,e),W.d(e),De[N].d(e),b(Xe,e),b(ze,e),b(Ee,e),qe[A].d(e),b(z,e),k&&k.d(e)}}}const ql='{"title":"Processing the data","local":"processing-the-data","sections":[{"title":"Loading a dataset from the Hub","local":"loading-a-dataset-from-the-hub","sections":[],"depth":3},{"title":"Preprocessing a dataset","local":"preprocessing-a-dataset","sections":[],"depth":3},{"title":"Dynamic padding","local":"dynamic-padding","sections":[],"depth":3}],"depth":1}';function Ll(w,t,i){let l="pt";return kl(()=>{const p=new URLSearchParams(window.location.search);i(0,l=p.get("fw")||"pt")}),[l]}class an extends _l{constructor(t){super(),$l(this,t,Ll,Dl,gl,{})}}export{an as component};
