import{s as xl,o as Il,n as _t}from"../chunks/scheduler.37c15a92.js";import{S as vl,i as Rl,g as d,s as o,r as m,A as Zl,h as u,f as n,c as r,j as kl,u as f,x as y,k as $l,y as Nl,a,v as j,t as M,b as Ke,d as c,w as b,m as Al,n as Ql,p as Oe}from"../chunks/index.7cb9c9b8.js";import{T as bt}from"../chunks/Tip.d10b3fc9.js";import{Y as ps}from"../chunks/Youtube.8666c400.js";import{C as U}from"../chunks/CodeBlock.abae2786.js";import{C as Cl}from"../chunks/CourseFloatingBanner.df82c153.js";import{F as Gl}from"../chunks/FrameworkSwitchCourse.97630871.js";import{H as wt,E as Bl}from"../chunks/index.706e2c58.js";function Wl(w){let t,i;return t=new Cl({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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Xl(w){let t,i;return t=new Cl({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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}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 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(h){t=u(h,"P",{"data-svelte-h":!0}),y(t)!=="svelte-1bedvbw"&&(t.innerHTML=i),l=r(h),f(p.$$.fragment,h)},m(h,g){a(h,t,g),a(h,l,g),j(p,h,g),T=!0},i(h){T||(c(p.$$.fragment,h),T=!0)},o(h){M(p.$$.fragment,h),T=!1},d(h){h&&(n(t),n(l)),b(p,h)}}}function Vl(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:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwdG9yY2gub3B0aW0lMjBpbXBvcnQlMjBBZGFtVyUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvVG9rZW5pemVyJTJDJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQSUyMyUyMFNhbWUlMjBhcyUyMGJlZm9yZSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQXNlcXVlbmNlcyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMkkndmUlMjBiZWVuJTIwd2FpdGluZyUyMGZvciUyMGElMjBIdWdnaW5nRmFjZSUyMGNvdXJzZSUyMG15JTIwd2hvbGUlMjBsaWZlLiUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMlRoaXMlMjBjb3Vyc2UlMjBpcyUyMGFtYXppbmchJTIyJTJDJTBBJTVEJTBBYmF0Y2glMjAlM0QlMjB0b2tlbml6ZXIoc2VxdWVuY2VzJTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBJTIzJTIwVGhpcyUyMGlzJTIwbmV3JTBBYmF0Y2glNUIlMjJsYWJlbHMlMjIlNUQlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCMSUyQyUyMDElNUQpJTBBJTBBb3B0aW1pemVyJTIwJTNEJTIwQWRhbVcobW9kZWwucGFyYW1ldGVycygpKSUwQWxvc3MlMjAlM0QlMjBtb2RlbCgqKmJhdGNoKS5sb3NzJTBBbG9zcy5iYWNrd2FyZCgpJTBBb3B0aW1pemVyLnN0ZXAoKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> 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(h){t=u(h,"P",{"data-svelte-h":!0}),y(t)!=="svelte-18ln3r8"&&(t.innerHTML=i),l=r(h),f(p.$$.fragment,h)},m(h,g){a(h,t,g),a(h,l,g),j(p,h,g),T=!0},i(h){T||(c(p.$$.fragment,h),T=!0)},o(h){M(p.$$.fragment,h),T=!1},d(h){h&&(n(t),n(l)),b(p,h)}}}function El(w){let t,i;return t=new ps({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||(c(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 ps({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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Sl(w){let t;return{c(){t=Al("⚠️ **Warning** Make sure that `datasets` is installed by running `pip install datasets`. Then, load the MRPC dataset and print it to see what it contains.")},l(i){t=Ql(i,"⚠️ **Warning** Make sure that `datasets` is installed by running `pip install datasets`. Then, load the MRPC dataset and print it to see what it contains.")},m(i,l){a(i,t,l)},d(i){i&&n(t)}}}function Yl(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:_t,d(l){l&&n(t)}}}function Fl(w){let t,i;return t=new ps({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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Dl(w){let t,i;return t=new ps({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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function ql(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:_t,d(l){l&&n(t)}}}function Ll(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 Pl(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 Kl(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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function Ol(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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function en(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(h){f(t.$$.fragment,h),i=r(h),l=u(h,"P",{"data-svelte-h":!0}),y(l)!=="svelte-3l70up"&&(l.textContent=p)},m(h,g){j(t,h,g),a(h,i,g),a(h,l,g),T=!0},i(h){T||(c(t.$$.fragment,h),T=!0)},o(h){M(t.$$.fragment,h),T=!1},d(h){h&&(n(i),n(l)),b(t,h)}}}function sn(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||(c(t.$$.fragment,l),i=!0)},o(l){M(t.$$.fragment,l),i=!1},d(l){b(t,l)}}}function tn(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:_t,d(l){l&&n(t)}}}function _l(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,h,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(),h=d("p"),h.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),h=u(J,"P",{"data-svelte-h":!0}),y(h)!=="svelte-2qcqqp"&&(h.textContent=g)},m(J,$){a(J,t,$),a(J,l,$),j(p,J,$),a(J,T,$),a(J,h,$),G=!0},i(J){G||(c(p.$$.fragment,J),G=!0)},o(J){M(p.$$.fragment,J),G=!1},d(J){J&&(n(t),n(l),n(T),n(h)),b(p,J)}}}function ln(w){let t,i,l,p,T,h,g,G,J,$,es,_,C,ss,E,Ct="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.",cs,H,xt='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.',hs,S,Ms,x,I,ts,Y,It='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.',ds,F,vt="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:",us,W,ys,D,ms,q,fs,L,Rt="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).",js,P,Zt="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.",bs,K,Nt="We can access each pair of sentences in our <code>raw_datasets</code> object by indexing, like with a dictionary:",ws,O,Js,ee,Ts,se,At="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:",Us,te,gs,le,ks,ne,Qt="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>.",$s,X,_s,ae,Cs,v,R,ls,ie,Gt='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:',xs,oe,Is,re,Bt="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:",vs,pe,Rs,ce,Zs,he,Wt='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.',Ns,z,As,Me,Xt="If we decode the IDs inside <code>input_ids</code> back to words:",Qs,de,Gs,ue,zt="we will get:",Bs,ye,Ws,me,Vt="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:",Xs,fe,zs,je,Et="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>.",Vs,be,Ht="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.",Es,we,St='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.',Hs,Je,Yt="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.",Ss,Te,Ft="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.",Ys,Ue,Dt='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:',Fs,ge,Ds,ke,qt='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).',qs,$e,Lt='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:',Ls,_e,Ps,Ce,Pt='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.',Ks,xe,Kt="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!",Os,Ie,Ot="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.",et,ve,st,Re,el="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:",tt,Ze,lt,Ne,sl="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.",nt,Ae,tl="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>.",at,Qe,ll="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>.",it,Ge,ot,Be,rt,ns,We,nl="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:",pt,Z,N,as,Xe,al="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:",ct,ze,ht,Ve,Mt,Ee,il="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:",dt,He,ut,A,Q,is,V,yt,os,Se,mt,rs,ft;T=new Gl({props:{fw:w[0]}}),g=new wt({props:{title:"Processing the data",local:"processing-the-data",headingTag:"h1"}});const ol=[Xl,Wl],Ye=[];function rl(e,s){return e[0]==="pt"?0:1}J=rl(w),$=Ye[J]=ol[J](w);const pl=[Vl,zl],Fe=[];function cl(e,s){return e[0]==="pt"?0:1}_=cl(w),C=Fe[_]=pl[_](w),S=new wt({props:{title:"Loading a dataset from the Hub",local:"loading-a-dataset-from-the-hub",headingTag:"h3"}});const hl=[Hl,El],De=[];function Ml(e,s){return e[0]==="pt"?0:1}x=Ml(w),I=De[x]=hl[x](w),W=new bt({props:{$$slots:{default:[Sl]},$$scope:{ctx:w}}}),D=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}}),q=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}}),O=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}}),ee=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}}),te=new U({props:{code:"cmF3X3RyYWluX2RhdGFzZXQuZmVhdHVyZXM=",highlighted:"raw_train_dataset.features",wrap:!1}}),le=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}}),X=new bt({props:{$$slots:{default:[Yl]},$$scope:{ctx:w}}}),ae=new wt({props:{title:"Preprocessing a dataset",local:"preprocessing-a-dataset",headingTag:"h3"}});const dl=[Dl,Fl],qe=[];function ul(e,s){return e[0]==="pt"?0:1}v=ul(w),R=qe[v]=dl[v](w),oe=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}}),pe=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}}),ce=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}}),z=new bt({props:{$$slots:{default:[ql]},$$scope:{ctx:w}}}),de=new U({props:{code:"dG9rZW5pemVyLmNvbnZlcnRfaWRzX3RvX3Rva2VucyhpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQp",highlighted:'tokenizer.convert_ids_to_tokens(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>])',wrap:!1}}),ye=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}}),fe=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}}),ge=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}}),ve=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}}),Ze=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}}),Ge=new wt({props:{title:"Dynamic padding",local:"dynamic-padding",headingTag:"h3"}}),Be=new ps({props:{id:"7q5NyFT8REg"}});function yl(e,s){return e[0]==="pt"?Pl:Ll}let jt=yl(w),B=jt(w);const ml=[Ol,Kl],Le=[];function fl(e,s){return e[0]==="pt"?0:1}Z=fl(w),N=Le[Z]=ml[Z](w),ze=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}}),Ve=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}}),He=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 jl=[sn,en],Pe=[];function bl(e,s){return e[0]==="tf"?0:1}A=bl(w),Q=Pe[A]=jl[A](w),V=new bt({props:{$$slots:{default:[tn]},$$scope:{ctx:w}}});let k=w[0]==="tf"&&_l();return Se=new Bl({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter3/2.mdx"}}),{c(){t=d("meta"),i=o(),l=d("p"),p=o(),m(T.$$.fragment),h=o(),m(g.$$.fragment),G=o(),$.c(),es=o(),C.c(),ss=o(),E=d("p"),E.textContent=Ct,cs=o(),H=d("p"),H.innerHTML=xt,hs=o(),m(S.$$.fragment),Ms=o(),I.c(),ts=o(),Y=d("p"),Y.innerHTML=It,ds=o(),F=d("p"),F.textContent=vt,us=o(),m(W.$$.fragment),ys=o(),m(D.$$.fragment),ms=o(),m(q.$$.fragment),fs=o(),L=d("p"),L.innerHTML=Rt,js=o(),P=d("p"),P.innerHTML=Zt,bs=o(),K=d("p"),K.innerHTML=Nt,ws=o(),m(O.$$.fragment),Js=o(),m(ee.$$.fragment),Ts=o(),se=d("p"),se.innerHTML=At,Us=o(),m(te.$$.fragment),gs=o(),m(le.$$.fragment),ks=o(),ne=d("p"),ne.innerHTML=Qt,$s=o(),m(X.$$.fragment),_s=o(),m(ae.$$.fragment),Cs=o(),R.c(),ls=o(),ie=d("p"),ie.innerHTML=Gt,xs=o(),m(oe.$$.fragment),Is=o(),re=d("p"),re.textContent=Bt,vs=o(),m(pe.$$.fragment),Rs=o(),m(ce.$$.fragment),Zs=o(),he=d("p"),he.innerHTML=Wt,Ns=o(),m(z.$$.fragment),As=o(),Me=d("p"),Me.innerHTML=Xt,Qs=o(),m(de.$$.fragment),Gs=o(),ue=d("p"),ue.textContent=zt,Bs=o(),m(ye.$$.fragment),Ws=o(),me=d("p"),me.innerHTML=Vt,Xs=o(),m(fe.$$.fragment),zs=o(),je=d("p"),je.innerHTML=Et,Vs=o(),be=d("p"),be.innerHTML=Ht,Es=o(),we=d("p"),we.innerHTML=St,Hs=o(),Je=d("p"),Je.textContent=Yt,Ss=o(),Te=d("p"),Te.innerHTML=Ft,Ys=o(),Ue=d("p"),Ue.innerHTML=Dt,Fs=o(),m(ge.$$.fragment),Ds=o(),ke=d("p"),ke.innerHTML=qt,qs=o(),$e=d("p"),$e.innerHTML=Lt,Ls=o(),m(_e.$$.fragment),Ps=o(),Ce=d("p"),Ce.innerHTML=Pt,Ks=o(),xe=d("p"),xe.innerHTML=Kt,Os=o(),Ie=d("p"),Ie.innerHTML=Ot,et=o(),m(ve.$$.fragment),st=o(),Re=d("p"),Re.textContent=el,tt=o(),m(Ze.$$.fragment),lt=o(),Ne=d("p"),Ne.innerHTML=sl,nt=o(),Ae=d("p"),Ae.innerHTML=tl,at=o(),Qe=d("p"),Qe.innerHTML=ll,it=o(),m(Ge.$$.fragment),ot=o(),m(Be.$$.fragment),rt=o(),B.c(),ns=o(),We=d("p"),We.innerHTML=nl,pt=o(),N.c(),as=o(),Xe=d("p"),Xe.innerHTML=al,ct=o(),m(ze.$$.fragment),ht=o(),m(Ve.$$.fragment),Mt=o(),Ee=d("p"),Ee.innerHTML=il,dt=o(),m(He.$$.fragment),ut=o(),Q.c(),is=o(),m(V.$$.fragment),yt=o(),k&&k.c(),os=o(),m(Se.$$.fragment),mt=o(),rs=d("p"),this.h()},l(e){const s=Zl("svelte-u9bgzb",document.head);t=u(s,"META",{name:!0,content:!0}),s.forEach(n),i=r(e),l=u(e,"P",{}),kl(l).forEach(n),p=r(e),f(T.$$.fragment,e),h=r(e),f(g.$$.fragment,e),G=r(e),$.l(e),es=r(e),C.l(e),ss=r(e),E=u(e,"P",{"data-svelte-h":!0}),y(E)!=="svelte-k42f7q"&&(E.textContent=Ct),cs=r(e),H=u(e,"P",{"data-svelte-h":!0}),y(H)!=="svelte-zjffq0"&&(H.innerHTML=xt),hs=r(e),f(S.$$.fragment,e),Ms=r(e),I.l(e),ts=r(e),Y=u(e,"P",{"data-svelte-h":!0}),y(Y)!=="svelte-1l7s9ct"&&(Y.innerHTML=It),ds=r(e),F=u(e,"P",{"data-svelte-h":!0}),y(F)!=="svelte-a0uedu"&&(F.textContent=vt),us=r(e),f(W.$$.fragment,e),ys=r(e),f(D.$$.fragment,e),ms=r(e),f(q.$$.fragment,e),fs=r(e),L=u(e,"P",{"data-svelte-h":!0}),y(L)!=="svelte-1c0bj8y"&&(L.innerHTML=Rt),js=r(e),P=u(e,"P",{"data-svelte-h":!0}),y(P)!=="svelte-124lsw3"&&(P.innerHTML=Zt),bs=r(e),K=u(e,"P",{"data-svelte-h":!0}),y(K)!=="svelte-65xqw4"&&(K.innerHTML=Nt),ws=r(e),f(O.$$.fragment,e),Js=r(e),f(ee.$$.fragment,e),Ts=r(e),se=u(e,"P",{"data-svelte-h":!0}),y(se)!=="svelte-1o36uf9"&&(se.innerHTML=At),Us=r(e),f(te.$$.fragment,e),gs=r(e),f(le.$$.fragment,e),ks=r(e),ne=u(e,"P",{"data-svelte-h":!0}),y(ne)!=="svelte-1c3slq1"&&(ne.innerHTML=Qt),$s=r(e),f(X.$$.fragment,e),_s=r(e),f(ae.$$.fragment,e),Cs=r(e),R.l(e),ls=r(e),ie=u(e,"P",{"data-svelte-h":!0}),y(ie)!=="svelte-cvke6e"&&(ie.innerHTML=Gt),xs=r(e),f(oe.$$.fragment,e),Is=r(e),re=u(e,"P",{"data-svelte-h":!0}),y(re)!=="svelte-17gxq0h"&&(re.textContent=Bt),vs=r(e),f(pe.$$.fragment,e),Rs=r(e),f(ce.$$.fragment,e),Zs=r(e),he=u(e,"P",{"data-svelte-h":!0}),y(he)!=="svelte-s9c1sv"&&(he.innerHTML=Wt),Ns=r(e),f(z.$$.fragment,e),As=r(e),Me=u(e,"P",{"data-svelte-h":!0}),y(Me)!=="svelte-17ajvt1"&&(Me.innerHTML=Xt),Qs=r(e),f(de.$$.fragment,e),Gs=r(e),ue=u(e,"P",{"data-svelte-h":!0}),y(ue)!=="svelte-1oivwa"&&(ue.textContent=zt),Bs=r(e),f(ye.$$.fragment,e),Ws=r(e),me=u(e,"P",{"data-svelte-h":!0}),y(me)!=="svelte-1tvepx7"&&(me.innerHTML=Vt),Xs=r(e),f(fe.$$.fragment,e),zs=r(e),je=u(e,"P",{"data-svelte-h":!0}),y(je)!=="svelte-10hqnfn"&&(je.innerHTML=Et),Vs=r(e),be=u(e,"P",{"data-svelte-h":!0}),y(be)!=="svelte-hspdt8"&&(be.innerHTML=Ht),Es=r(e),we=u(e,"P",{"data-svelte-h":!0}),y(we)!=="svelte-11u1x7y"&&(we.innerHTML=St),Hs=r(e),Je=u(e,"P",{"data-svelte-h":!0}),y(Je)!=="svelte-1e7se1j"&&(Je.textContent=Yt),Ss=r(e),Te=u(e,"P",{"data-svelte-h":!0}),y(Te)!=="svelte-1ujm1f5"&&(Te.innerHTML=Ft),Ys=r(e),Ue=u(e,"P",{"data-svelte-h":!0}),y(Ue)!=="svelte-57wndc"&&(Ue.innerHTML=Dt),Fs=r(e),f(ge.$$.fragment,e),Ds=r(e),ke=u(e,"P",{"data-svelte-h":!0}),y(ke)!=="svelte-12m6ruz"&&(ke.innerHTML=qt),qs=r(e),$e=u(e,"P",{"data-svelte-h":!0}),y($e)!=="svelte-ykgx4y"&&($e.innerHTML=Lt),Ls=r(e),f(_e.$$.fragment,e),Ps=r(e),Ce=u(e,"P",{"data-svelte-h":!0}),y(Ce)!=="svelte-1jfj8zf"&&(Ce.innerHTML=Pt),Ks=r(e),xe=u(e,"P",{"data-svelte-h":!0}),y(xe)!=="svelte-ko1qsu"&&(xe.innerHTML=Kt),Os=r(e),Ie=u(e,"P",{"data-svelte-h":!0}),y(Ie)!=="svelte-oo95cw"&&(Ie.innerHTML=Ot),et=r(e),f(ve.$$.fragment,e),st=r(e),Re=u(e,"P",{"data-svelte-h":!0}),y(Re)!=="svelte-12x3mv1"&&(Re.textContent=el),tt=r(e),f(Ze.$$.fragment,e),lt=r(e),Ne=u(e,"P",{"data-svelte-h":!0}),y(Ne)!=="svelte-b2zdkp"&&(Ne.innerHTML=sl),nt=r(e),Ae=u(e,"P",{"data-svelte-h":!0}),y(Ae)!=="svelte-k426ib"&&(Ae.innerHTML=tl),at=r(e),Qe=u(e,"P",{"data-svelte-h":!0}),y(Qe)!=="svelte-1onxd79"&&(Qe.innerHTML=ll),it=r(e),f(Ge.$$.fragment,e),ot=r(e),f(Be.$$.fragment,e),rt=r(e),B.l(e),ns=r(e),We=u(e,"P",{"data-svelte-h":!0}),y(We)!=="svelte-1b915t7"&&(We.innerHTML=nl),pt=r(e),N.l(e),as=r(e),Xe=u(e,"P",{"data-svelte-h":!0}),y(Xe)!=="svelte-1dw0kzt"&&(Xe.innerHTML=al),ct=r(e),f(ze.$$.fragment,e),ht=r(e),f(Ve.$$.fragment,e),Mt=r(e),Ee=u(e,"P",{"data-svelte-h":!0}),y(Ee)!=="svelte-1g0r85d"&&(Ee.innerHTML=il),dt=r(e),f(He.$$.fragment,e),ut=r(e),Q.l(e),is=r(e),f(V.$$.fragment,e),yt=r(e),k&&k.l(e),os=r(e),f(Se.$$.fragment,e),mt=r(e),rs=u(e,"P",{}),kl(rs).forEach(n),this.h()},h(){$l(t,"name","hf:doc:metadata"),$l(t,"content",nn)},m(e,s){Nl(document.head,t),a(e,i,s),a(e,l,s),a(e,p,s),j(T,e,s),a(e,h,s),j(g,e,s),a(e,G,s),Ye[J].m(e,s),a(e,es,s),Fe[_].m(e,s),a(e,ss,s),a(e,E,s),a(e,cs,s),a(e,H,s),a(e,hs,s),j(S,e,s),a(e,Ms,s),De[x].m(e,s),a(e,ts,s),a(e,Y,s),a(e,ds,s),a(e,F,s),a(e,us,s),j(W,e,s),a(e,ys,s),j(D,e,s),a(e,ms,s),j(q,e,s),a(e,fs,s),a(e,L,s),a(e,js,s),a(e,P,s),a(e,bs,s),a(e,K,s),a(e,ws,s),j(O,e,s),a(e,Js,s),j(ee,e,s),a(e,Ts,s),a(e,se,s),a(e,Us,s),j(te,e,s),a(e,gs,s),j(le,e,s),a(e,ks,s),a(e,ne,s),a(e,$s,s),j(X,e,s),a(e,_s,s),j(ae,e,s),a(e,Cs,s),qe[v].m(e,s),a(e,ls,s),a(e,ie,s),a(e,xs,s),j(oe,e,s),a(e,Is,s),a(e,re,s),a(e,vs,s),j(pe,e,s),a(e,Rs,s),j(ce,e,s),a(e,Zs,s),a(e,he,s),a(e,Ns,s),j(z,e,s),a(e,As,s),a(e,Me,s),a(e,Qs,s),j(de,e,s),a(e,Gs,s),a(e,ue,s),a(e,Bs,s),j(ye,e,s),a(e,Ws,s),a(e,me,s),a(e,Xs,s),j(fe,e,s),a(e,zs,s),a(e,je,s),a(e,Vs,s),a(e,be,s),a(e,Es,s),a(e,we,s),a(e,Hs,s),a(e,Je,s),a(e,Ss,s),a(e,Te,s),a(e,Ys,s),a(e,Ue,s),a(e,Fs,s),j(ge,e,s),a(e,Ds,s),a(e,ke,s),a(e,qs,s),a(e,$e,s),a(e,Ls,s),j(_e,e,s),a(e,Ps,s),a(e,Ce,s),a(e,Ks,s),a(e,xe,s),a(e,Os,s),a(e,Ie,s),a(e,et,s),j(ve,e,s),a(e,st,s),a(e,Re,s),a(e,tt,s),j(Ze,e,s),a(e,lt,s),a(e,Ne,s),a(e,nt,s),a(e,Ae,s),a(e,at,s),a(e,Qe,s),a(e,it,s),j(Ge,e,s),a(e,ot,s),j(Be,e,s),a(e,rt,s),B.m(e,s),a(e,ns,s),a(e,We,s),a(e,pt,s),Le[Z].m(e,s),a(e,as,s),a(e,Xe,s),a(e,ct,s),j(ze,e,s),a(e,ht,s),j(Ve,e,s),a(e,Mt,s),a(e,Ee,s),a(e,dt,s),j(He,e,s),a(e,ut,s),Pe[A].m(e,s),a(e,is,s),j(V,e,s),a(e,yt,s),k&&k.m(e,s),a(e,os,s),j(Se,e,s),a(e,mt,s),a(e,rs,s),ft=!0},p(e,[s]){const wl={};s&1&&(wl.fw=e[0]),T.$set(wl);let Jt=J;J=rl(e),J!==Jt&&(Oe(),M(Ye[Jt],1,1,()=>{Ye[Jt]=null}),Ke(),$=Ye[J],$||($=Ye[J]=ol[J](e),$.c()),c($,1),$.m(es.parentNode,es));let Tt=_;_=cl(e),_!==Tt&&(Oe(),M(Fe[Tt],1,1,()=>{Fe[Tt]=null}),Ke(),C=Fe[_],C||(C=Fe[_]=pl[_](e),C.c()),c(C,1),C.m(ss.parentNode,ss));let Ut=x;x=Ml(e),x!==Ut&&(Oe(),M(De[Ut],1,1,()=>{De[Ut]=null}),Ke(),I=De[x],I||(I=De[x]=hl[x](e),I.c()),c(I,1),I.m(ts.parentNode,ts));const Jl={};s&2&&(Jl.$$scope={dirty:s,ctx:e}),W.$set(Jl);const Tl={};s&2&&(Tl.$$scope={dirty:s,ctx:e}),X.$set(Tl);let gt=v;v=ul(e),v!==gt&&(Oe(),M(qe[gt],1,1,()=>{qe[gt]=null}),Ke(),R=qe[v],R||(R=qe[v]=dl[v](e),R.c()),c(R,1),R.m(ls.parentNode,ls));const Ul={};s&2&&(Ul.$$scope={dirty:s,ctx:e}),z.$set(Ul),jt!==(jt=yl(e))&&(B.d(1),B=jt(e),B&&(B.c(),B.m(ns.parentNode,ns)));let kt=Z;Z=fl(e),Z!==kt&&(Oe(),M(Le[kt],1,1,()=>{Le[kt]=null}),Ke(),N=Le[Z],N||(N=Le[Z]=ml[Z](e),N.c()),c(N,1),N.m(as.parentNode,as));let $t=A;A=bl(e),A!==$t&&(Oe(),M(Pe[$t],1,1,()=>{Pe[$t]=null}),Ke(),Q=Pe[A],Q||(Q=Pe[A]=jl[A](e),Q.c()),c(Q,1),Q.m(is.parentNode,is));const gl={};s&2&&(gl.$$scope={dirty:s,ctx:e}),V.$set(gl),e[0]==="tf"?k?s&1&&c(k,1):(k=_l(),k.c(),c(k,1),k.m(os.parentNode,os)):k&&(Oe(),M(k,1,1,()=>{k=null}),Ke())},i(e){ft||(c(T.$$.fragment,e),c(g.$$.fragment,e),c($),c(C),c(S.$$.fragment,e),c(I),c(W.$$.fragment,e),c(D.$$.fragment,e),c(q.$$.fragment,e),c(O.$$.fragment,e),c(ee.$$.fragment,e),c(te.$$.fragment,e),c(le.$$.fragment,e),c(X.$$.fragment,e),c(ae.$$.fragment,e),c(R),c(oe.$$.fragment,e),c(pe.$$.fragment,e),c(ce.$$.fragment,e),c(z.$$.fragment,e),c(de.$$.fragment,e),c(ye.$$.fragment,e),c(fe.$$.fragment,e),c(ge.$$.fragment,e),c(_e.$$.fragment,e),c(ve.$$.fragment,e),c(Ze.$$.fragment,e),c(Ge.$$.fragment,e),c(Be.$$.fragment,e),c(N),c(ze.$$.fragment,e),c(Ve.$$.fragment,e),c(He.$$.fragment,e),c(Q),c(V.$$.fragment,e),c(k),c(Se.$$.fragment,e),ft=!0)},o(e){M(T.$$.fragment,e),M(g.$$.fragment,e),M($),M(C),M(S.$$.fragment,e),M(I),M(W.$$.fragment,e),M(D.$$.fragment,e),M(q.$$.fragment,e),M(O.$$.fragment,e),M(ee.$$.fragment,e),M(te.$$.fragment,e),M(le.$$.fragment,e),M(X.$$.fragment,e),M(ae.$$.fragment,e),M(R),M(oe.$$.fragment,e),M(pe.$$.fragment,e),M(ce.$$.fragment,e),M(z.$$.fragment,e),M(de.$$.fragment,e),M(ye.$$.fragment,e),M(fe.$$.fragment,e),M(ge.$$.fragment,e),M(_e.$$.fragment,e),M(ve.$$.fragment,e),M(Ze.$$.fragment,e),M(Ge.$$.fragment,e),M(Be.$$.fragment,e),M(N),M(ze.$$.fragment,e),M(Ve.$$.fragment,e),M(He.$$.fragment,e),M(Q),M(V.$$.fragment,e),M(k),M(Se.$$.fragment,e),ft=!1},d(e){e&&(n(i),n(l),n(p),n(h),n(G),n(es),n(ss),n(E),n(cs),n(H),n(hs),n(Ms),n(ts),n(Y),n(ds),n(F),n(us),n(ys),n(ms),n(fs),n(L),n(js),n(P),n(bs),n(K),n(ws),n(Js),n(Ts),n(se),n(Us),n(gs),n(ks),n(ne),n($s),n(_s),n(Cs),n(ls),n(ie),n(xs),n(Is),n(re),n(vs),n(Rs),n(Zs),n(he),n(Ns),n(As),n(Me),n(Qs),n(Gs),n(ue),n(Bs),n(Ws),n(me),n(Xs),n(zs),n(je),n(Vs),n(be),n(Es),n(we),n(Hs),n(Je),n(Ss),n(Te),n(Ys),n(Ue),n(Fs),n(Ds),n(ke),n(qs),n($e),n(Ls),n(Ps),n(Ce),n(Ks),n(xe),n(Os),n(Ie),n(et),n(st),n(Re),n(tt),n(lt),n(Ne),n(nt),n(Ae),n(at),n(Qe),n(it),n(ot),n(rt),n(ns),n(We),n(pt),n(as),n(Xe),n(ct),n(ht),n(Mt),n(Ee),n(dt),n(ut),n(is),n(yt),n(os),n(mt),n(rs)),n(t),b(T,e),b(g,e),Ye[J].d(e),Fe[_].d(e),b(S,e),De[x].d(e),b(W,e),b(D,e),b(q,e),b(O,e),b(ee,e),b(te,e),b(le,e),b(X,e),b(ae,e),qe[v].d(e),b(oe,e),b(pe,e),b(ce,e),b(z,e),b(de,e),b(ye,e),b(fe,e),b(ge,e),b(_e,e),b(ve,e),b(Ze,e),b(Ge,e),b(Be,e),B.d(e),Le[Z].d(e),b(ze,e),b(Ve,e),b(He,e),Pe[A].d(e),b(V,e),k&&k.d(e),b(Se,e)}}}const nn='{"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 an(w,t,i){let l="pt";return Il(()=>{const p=new URLSearchParams(window.location.search);i(0,l=p.get("fw")||"pt")}),[l]}class yn extends vl{constructor(t){super(),Rl(this,t,an,ln,xl,{})}}export{yn as component};
