import{S as kh,i as Eh,s as Dh,e as n,k as c,w as _,t,M as Ah,c as r,d as a,m as f,a as o,x as v,h as l,b as h,N as yh,G as s,g as i,y as j,q as b,o as x,B as $,v as Ih,L as Th}from"../chunks/vendor-hf-doc-builder.js";import{T as St}from"../chunks/Tip-hf-doc-builder.js";import{I as M}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as T}from"../chunks/CodeBlock-hf-doc-builder.js";import{F as Sh,M as Ph}from"../chunks/Markdown-hf-doc-builder.js";import"../chunks/IconTensorflow-hf-doc-builder.js";function qh(C){let d,w,m,y,k,g,E,u,D,A,S;return{c(){d=n("p"),w=t("An "),m=n("a"),y=t("IterableDataset"),k=t(` is useful for iterative jobs like training a model.
You shouldn\u2019t use a `),g=n("a"),E=t("IterableDataset"),u=t(` for jobs that require random access to examples because you have to iterate all over it using a for loop. Getting the last example in an iterable dataset would require you to iterate over all the previous examples.
You can find more details in the `),D=n("a"),A=t("Dataset vs. IterableDataset guide"),S=t("."),this.h()},l(z){d=r(z,"P",{});var P=o(d);w=l(P,"An "),m=r(P,"A",{href:!0});var q=o(m);y=l(q,"IterableDataset"),q.forEach(a),k=l(P,` is useful for iterative jobs like training a model.
You shouldn\u2019t use a `),g=r(P,"A",{href:!0});var I=o(g);E=l(I,"IterableDataset"),I.forEach(a),u=l(P,` for jobs that require random access to examples because you have to iterate all over it using a for loop. Getting the last example in an iterable dataset would require you to iterate over all the previous examples.
You can find more details in the `),D=r(P,"A",{href:!0});var Q=o(D);A=l(Q,"Dataset vs. IterableDataset guide"),Q.forEach(a),S=l(P,"."),P.forEach(a),this.h()},h(){h(m,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(g,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(D,"href","./about_mapstyle_vs_iterable")},m(z,P){i(z,d,P),s(d,w),s(d,m),s(m,y),s(d,k),s(d,g),s(g,E),s(d,u),s(d,D),s(D,A),s(d,S)},d(z){z&&a(d)}}}function Ch(C){let d,w,m,y;return{c(){d=n("p"),w=n("a"),m=t("IterableDataset.shuffle()"),y=t(" will also shuffle the order of the shards if the dataset is sharded into multiple files."),this.h()},l(k){d=r(k,"P",{});var g=o(d);w=r(g,"A",{href:!0});var E=o(w);m=l(E,"IterableDataset.shuffle()"),E.forEach(a),y=l(g," will also shuffle the order of the shards if the dataset is sharded into multiple files."),g.forEach(a),this.h()},h(){h(w,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.shuffle")},m(k,g){i(k,d,g),s(d,w),s(w,m),s(d,y)},d(k){k&&a(d)}}}function zh(C){let d,w,m,y,k,g,E,u,D,A,S,z,P;return{c(){d=n("p"),w=n("code"),m=t("take"),y=t(" and "),k=n("code"),g=t("skip"),E=t(" prevent future calls to "),u=n("code"),D=t("shuffle"),A=t(" because they lock in the order of the shards. You should "),S=n("code"),z=t("shuffle"),P=t(" your dataset before splitting it.")},l(q){d=r(q,"P",{});var I=o(d);w=r(I,"CODE",{});var Q=o(w);m=l(Q,"take"),Q.forEach(a),y=l(I," and "),k=r(I,"CODE",{});var Cs=o(k);g=l(Cs,"skip"),Cs.forEach(a),E=l(I," prevent future calls to "),u=r(I,"CODE",{});var ge=o(u);D=l(ge,"shuffle"),ge.forEach(a),A=l(I," because they lock in the order of the shards. You should "),S=r(I,"CODE",{});var zs=o(S);z=l(zs,"shuffle"),zs.forEach(a),P=l(I," your dataset before splitting it."),I.forEach(a)},m(q,I){i(q,d,I),s(d,w),s(w,m),s(d,y),s(d,k),s(k,g),s(d,E),s(d,u),s(u,D),s(d,A),s(d,S),s(S,z),s(d,P)},d(q){q&&a(d)}}}function Nh(C){let d,w,m,y,k,g,E,u;return{c(){d=n("p"),w=t("Casting only works if the original feature type and new feature type are compatible. For example, you can cast a column with the feature type "),m=n("code"),y=t("Value('int32')"),k=t(" to "),g=n("code"),E=t("Value('bool')"),u=t(" if the original column only contains ones and zeros.")},l(D){d=r(D,"P",{});var A=o(d);w=l(A,"Casting only works if the original feature type and new feature type are compatible. For example, you can cast a column with the feature type "),m=r(A,"CODE",{});var S=o(m);y=l(S,"Value('int32')"),S.forEach(a),k=l(A," to "),g=r(A,"CODE",{});var z=o(g);E=l(z,"Value('bool')"),z.forEach(a),u=l(A," if the original column only contains ones and zeros."),A.forEach(a)},m(D,A){i(D,d,A),s(d,w),s(d,m),s(m,y),s(d,k),s(d,g),s(g,E),s(d,u)},d(D){D&&a(d)}}}function Lh(C){let d,w,m,y,k;return{c(){d=n("p"),w=t("See other examples of batch processing in the "),m=n("a"),y=t("batched map processing"),k=t(" documentation. They work the same for iterable datasets."),this.h()},l(g){d=r(g,"P",{});var E=o(d);w=l(E,"See other examples of batch processing in the "),m=r(E,"A",{href:!0});var u=o(m);y=l(u,"batched map processing"),u.forEach(a),k=l(E," documentation. They work the same for iterable datasets."),E.forEach(a),this.h()},h(){h(m,"href","./process#batch-processing")},m(g,E){i(g,d,E),s(d,w),s(d,m),s(m,y),s(d,k)},d(g){g&&a(d)}}}function Mh(C){let d,w,m,y,k,g,E;return d=new T({props:{code:`seed, buffer_size = 42, 10_000
dataset = dataset.shuffle(seed, buffer_size=buffer_size)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>seed, buffer_size = <span class="hljs-number">42</span>, <span class="hljs-number">10_000</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.shuffle(seed, buffer_size=buffer_size)`}}),g=new T({props:{code:`import torch
from torch.utils.data import DataLoader
from transformers import AutoModelForMaskedLM, DataCollatorForLanguageModeling
from tqdm import tqdm
dataset = dataset.with_format("torch")
dataloader = DataLoader(dataset, collate_fn=DataCollatorForLanguageModeling(tokenizer))
device = 'cuda' if torch.cuda.is_available() else 'cpu' 
model = AutoModelForMaskedLM.from_pretrained("distilbert-base-uncased")
model.train().to(device)
optimizer = torch.optim.AdamW(params=model.parameters(), lr=1e-5)
for epoch in range(3):
    dataset.set_epoch(epoch)
    for i, batch in enumerate(tqdm(dataloader, total=5)):
        if i == 5:
            break
        batch = {k: v.to(device) for k, v in batch.items()}
        outputs = model(**batch)
        loss = outputs[0]
        loss.backward()
        optimizer.step()
        optimizer.zero_grad()
        if i % 10 == 0:
            print(f"loss: {loss}")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForMaskedLM, DataCollatorForLanguageModeling
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm <span class="hljs-keyword">import</span> tqdm
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.with_format(<span class="hljs-string">&quot;torch&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataloader = DataLoader(dataset, collate_fn=DataCollatorForLanguageModeling(tokenizer))
<span class="hljs-meta">&gt;&gt;&gt; </span>device = <span class="hljs-string">&#x27;cuda&#x27;</span> <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;cpu&#x27;</span> 
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.train().to(device)
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = torch.optim.AdamW(params=model.parameters(), lr=<span class="hljs-number">1e-5</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">3</span>):
<span class="hljs-meta">... </span>    dataset.set_epoch(epoch)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> i, batch <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(tqdm(dataloader, total=<span class="hljs-number">5</span>)):
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i == <span class="hljs-number">5</span>:
<span class="hljs-meta">... </span>            <span class="hljs-keyword">break</span>
<span class="hljs-meta">... </span>        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs[<span class="hljs-number">0</span>]
<span class="hljs-meta">... </span>        loss.backward()
<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        <span class="hljs-keyword">if</span> i % <span class="hljs-number">10</span> == <span class="hljs-number">0</span>:
<span class="hljs-meta">... </span>            <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;loss: <span class="hljs-subst">{loss}</span>&quot;</span>)`}}),{c(){_(d.$$.fragment),w=c(),m=n("p"),y=t("Lastly, create a simple training loop and start training:"),k=c(),_(g.$$.fragment)},l(u){v(d.$$.fragment,u),w=f(u),m=r(u,"P",{});var D=o(m);y=l(D,"Lastly, create a simple training loop and start training:"),D.forEach(a),k=f(u),v(g.$$.fragment,u)},m(u,D){j(d,u,D),i(u,w,D),i(u,m,D),s(m,y),i(u,k,D),j(g,u,D),E=!0},p:Th,i(u){E||(b(d.$$.fragment,u),b(g.$$.fragment,u),E=!0)},o(u){x(d.$$.fragment,u),x(g.$$.fragment,u),E=!1},d(u){$(d,u),u&&a(w),u&&a(m),u&&a(k),$(g,u)}}}function Oh(C){let d,w;return d=new Ph({props:{$$slots:{default:[Mh]},$$scope:{ctx:C}}}),{c(){_(d.$$.fragment)},l(m){v(d.$$.fragment,m)},m(m,y){j(d,m,y),w=!0},p(m,y){const k={};y&2&&(k.$$scope={dirty:y,ctx:m}),d.$set(k)},i(m){w||(b(d.$$.fragment,m),w=!0)},o(m){x(d.$$.fragment,m),w=!1},d(m){$(d,m)}}}function Rh(C){let d,w,m,y,k,g,E,u,D,A,S,z,P,q,I,Q,Cs,ge,zs,$n,ka,wn,Pt,X,Ns,Ep,yn,Ls,Dp,qt,R,kn,Xe,En,Dn,Ea,An,In,Ms,Tn,Sn,Ct,Ze,zt,Os,Pn,Nt,U,Da,qn,Cn,Aa,zn,Nn,Ia,Ln,Lt,_e,Mn,es,On,Rn,Mt,ss,Ot,B,Fn,Rs,Yn,Vn,Fs,Hn,Un,Rt,ve,Ft,Z,je,Ta,as,Bn,Sa,Gn,Yt,F,Jn,Ys,Wn,Kn,Vs,Qn,Xn,Hs,Zn,er,Vt,Y,sr,Pa,ar,tr,qa,lr,nr,Us,rr,or,Ht,ts,Ut,be,Bt,ee,xe,Ca,ls,pr,za,ir,Gt,$e,hr,Na,cr,fr,Jt,we,dr,La,mr,ur,Wt,ns,Kt,se,ye,Ma,rs,gr,Oa,_r,Qt,Bs,vr,Xt,Gs,ke,Js,jr,br,Ra,xr,$r,Zt,os,el,Ws,Ee,Ks,wr,yr,Fa,kr,Er,sl,ps,al,De,tl,Qs,ll,ae,Ae,Ya,is,Dr,Va,Ar,nl,te,Xs,Ir,Tr,Zs,Sr,Pr,rl,hs,ol,Ie,qr,Ha,Cr,zr,pl,cs,il,G,Nr,Ua,Lr,Mr,Ba,Or,Rr,hl,L,Fr,Ga,Yr,Vr,Ja,Hr,Ur,Wa,Br,Gr,Ka,Jr,Wr,cl,le,Te,Qa,fs,Kr,Xa,Qr,fl,ea,Xr,dl,ne,Se,Za,ds,Zr,et,eo,ml,Pe,so,sa,ao,to,ul,qe,lo,aa,no,ro,gl,ms,_l,re,Ce,st,us,oo,at,po,vl,ze,io,ta,ho,co,jl,gs,bl,oe,Ne,tt,_s,fo,lt,mo,xl,O,la,uo,go,nt,_o,vo,rt,jo,bo,ot,xo,$o,$l,vs,wl,Le,yl,Me,wo,na,yo,ko,kl,js,El,pe,Oe,pt,bs,Eo,it,Do,Dl,N,Ao,ra,Io,To,oa,So,Po,pa,qo,Co,ia,zo,No,ha,Lo,Mo,Al,ca,Oo,Il,J,Ro,fa,Fo,Yo,ht,Vo,Ho,Tl,xs,Sl,Re,Uo,da,Bo,Go,Pl,$s,ql,Fe,Jo,ma,Wo,Ko,Cl,W,Qo,ct,Xo,Zo,ua,ep,sp,zl,ws,Nl,ie,Ye,ft,ys,ap,dt,tp,Ll,H,ga,lp,np,mt,rp,op,ut,pp,ip,Ml,he,Ve,gt,ks,hp,_t,cp,Ol,Es,Rl,He,Fl,ce,Ue,vt,Ds,fp,jt,dp,Yl,Be,mp,_a,up,gp,Vl,As,Hl,fe,va,_p,vp,bt,jp,bp,Ul,Is,Bl,de,Ge,xt,Ts,xp,$t,$p,Gl,Ss,ja,wp,yp,Jl,Je,Wl;return g=new M({}),Ze=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('oscar-corpus/OSCAR-2201', 'en', split='train', streaming=True)
print(next(iter(dataset)))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;oscar-corpus/OSCAR-2201&#x27;</span>, <span class="hljs-string">&#x27;en&#x27;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset)))
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Founded in 2015, Golden Bees is a leading programmatic recruitment platform dedicated to employers, HR agencies and job boards. The company has developed unique HR-custom technologies and predictive algorithms to identify and attract the best candidates for a job opportunity.&#x27;</span>, ...`}}),ss=new T({props:{code:`from datasets import load_dataset
data_files = {'train': 'path/to/OSCAR-2201/compressed/en_meta/*.jsonl.gz'}
dataset = load_dataset('json', data_files=data_files, split='train', streaming=True)
print(next(iter(dataset)))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>data_files = {<span class="hljs-string">&#x27;train&#x27;</span>: <span class="hljs-string">&#x27;path/to/OSCAR-2201/compressed/en_meta/*.jsonl.gz&#x27;</span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;json&#x27;</span>, data_files=data_files, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset)))
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Founded in 2015, Golden Bees is a leading programmatic recruitment platform dedicated to employers, HR agencies and job boards. The company has developed unique HR-custom technologies and predictive algorithms to identify and attract the best candidates for a job opportunity.&#x27;</span>, ...`}}),ve=new St({props:{$$slots:{default:[qh]},$$scope:{ctx:C}}}),as=new M({}),ts=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('oscar', "unshuffled_deduplicated_en", split='train', streaming=True)
shuffled_dataset = dataset.shuffle(seed=42, buffer_size=10_000)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&quot;unshuffled_deduplicated_en&quot;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>shuffled_dataset = dataset.shuffle(seed=<span class="hljs-number">42</span>, buffer_size=<span class="hljs-number">10_000</span>)`}}),be=new St({props:{$$slots:{default:[Ch]},$$scope:{ctx:C}}}),ls=new M({}),ns=new T({props:{code:`for epoch in range(epochs):
    shuffled_dataset.set_epoch(epoch)
    for example in shuffled_dataset:
        ...`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(epochs):
<span class="hljs-meta">... </span>    shuffled_dataset.set_epoch(epoch)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> shuffled_dataset:
<span class="hljs-meta">... </span>        ...`}}),rs=new M({}),os=new T({props:{code:`dataset = load_dataset('oscar', "unshuffled_deduplicated_en", split='train', streaming=True)
dataset_head = dataset.take(2)
list(dataset_head)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&quot;unshuffled_deduplicated_en&quot;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_head = dataset.take(<span class="hljs-number">2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(dataset_head)
[{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Mtendere Village was...&#x27;</span>}, {<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Lily James cannot fight the music...&#x27;</span>}]`}}),ps=new T({props:{code:"train_dataset = shuffled_dataset.skip(1000)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataset = shuffled_dataset.skip(<span class="hljs-number">1000</span>)'}}),De=new St({props:{warning:!0,$$slots:{default:[zh]},$$scope:{ctx:C}}}),is=new M({}),hs=new T({props:{code:`from datasets import interleave_datasets
en_dataset = load_dataset('oscar', "unshuffled_deduplicated_en", split='train', streaming=True)
fr_dataset = load_dataset('oscar', "unshuffled_deduplicated_fr", split='train', streaming=True)

multilingual_dataset = interleave_datasets([en_dataset, fr_dataset])
list(multilingual_dataset.take(2))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> interleave_datasets
<span class="hljs-meta">&gt;&gt;&gt; </span>en_dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&quot;unshuffled_deduplicated_en&quot;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>fr_dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&quot;unshuffled_deduplicated_fr&quot;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>multilingual_dataset = interleave_datasets([en_dataset, fr_dataset])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(multilingual_dataset.take(<span class="hljs-number">2</span>))
[{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Mtendere Village was inspired by the vision...&#x27;</span>}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&quot;M\xE9dia de d\xE9bat d&#x27;id\xE9es, de culture et de litt\xE9rature...&quot;</span>}]`}}),cs=new T({props:{code:`multilingual_dataset_with_oversampling = interleave_datasets([en_dataset, fr_dataset], probabilities=[0.8, 0.2], seed=42)
list(multilingual_dataset_with_oversampling.take(2))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>multilingual_dataset_with_oversampling = interleave_datasets([en_dataset, fr_dataset], probabilities=[<span class="hljs-number">0.8</span>, <span class="hljs-number">0.2</span>], seed=<span class="hljs-number">42</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(multilingual_dataset_with_oversampling.take(<span class="hljs-number">2</span>))
[{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Mtendere Village was inspired by the vision...&#x27;</span>}, {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Lily James cannot fight the music...&#x27;</span>}]`}}),fs=new M({}),ds=new M({}),ms=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('mc4', 'en', streaming=True, split='train')
dataset = dataset.rename_column("text", "content")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;mc4&#x27;</span>, <span class="hljs-string">&#x27;en&#x27;</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.rename_column(<span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>)`}}),us=new M({}),gs=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('mc4', 'en', streaming=True, split='train')
dataset = dataset.remove_columns('timestamp')`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;mc4&#x27;</span>, <span class="hljs-string">&#x27;en&#x27;</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.remove_columns(<span class="hljs-string">&#x27;timestamp&#x27;</span>)`}}),_s=new M({}),vs=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('glue', 'mrpc', split='train', streaming=True)
dataset.features

from datasets import ClassLabel, Value
new_features = dataset.features.copy()
new_features["label"] = ClassLabel(names=['negative', 'positive'])
new_features["idx"] = Value('int64')
dataset = dataset.cast(new_features)
dataset.features`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;glue&#x27;</span>, <span class="hljs-string">&#x27;mrpc&#x27;</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>, streaming=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.features
{<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>)}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> ClassLabel, Value
<span class="hljs-meta">&gt;&gt;&gt; </span>new_features = dataset.features.copy()
<span class="hljs-meta">&gt;&gt;&gt; </span>new_features[<span class="hljs-string">&quot;label&quot;</span>] = ClassLabel(names=[<span class="hljs-string">&#x27;negative&#x27;</span>, <span class="hljs-string">&#x27;positive&#x27;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span>new_features[<span class="hljs-string">&quot;idx&quot;</span>] = Value(<span class="hljs-string">&#x27;int64&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast(new_features)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.features
{<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;negative&#x27;</span>, <span class="hljs-string">&#x27;positive&#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;int64&#x27;</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)}`}}),Le=new St({props:{$$slots:{default:[Nh]},$$scope:{ctx:C}}}),js=new T({props:{code:`dataset.features

dataset = dataset.cast_column("audio", Audio(sampling_rate=16000))
dataset.features`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.features
{<span class="hljs-string">&#x27;audio&#x27;</span>: Audio(sampling_rate=<span class="hljs-number">44100</span>, mono=<span class="hljs-literal">True</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)}

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=<span class="hljs-number">16000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset.features
{<span class="hljs-string">&#x27;audio&#x27;</span>: Audio(sampling_rate=<span class="hljs-number">16000</span>, mono=<span class="hljs-literal">True</span>, <span class="hljs-built_in">id</span>=<span class="hljs-literal">None</span>)}`}}),bs=new M({}),xs=new T({props:{code:`def add_prefix(example):
    example['text'] = 'My text: ' + example['text']
    return example`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">add_prefix</span>(<span class="hljs-params">example</span>):
<span class="hljs-meta">... </span>    example[<span class="hljs-string">&#x27;text&#x27;</span>] = <span class="hljs-string">&#x27;My text: &#x27;</span> + example[<span class="hljs-string">&#x27;text&#x27;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> example`}}),$s=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('oscar', 'unshuffled_deduplicated_en', streaming=True, split='train')
updated_dataset = dataset.map(add_prefix)
list(updated_dataset.take(3))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&#x27;unshuffled_deduplicated_en&#x27;</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>updated_dataset = dataset.<span class="hljs-built_in">map</span>(add_prefix)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(updated_dataset.take(<span class="hljs-number">3</span>))
[{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: Mtendere Village was inspired by...&#x27;</span>},
 {<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: Lily James cannot fight the music...&#x27;</span>},
 {<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">2</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: &quot;I\\&#x27;d love to help kickstart...&#x27;</span>}]`}}),ws=new T({props:{code:`updated_dataset = dataset.map(add_prefix, remove_columns=["id"])
list(updated_dataset.take(3))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>updated_dataset = dataset.<span class="hljs-built_in">map</span>(add_prefix, remove_columns=[<span class="hljs-string">&quot;id&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(updated_dataset.take(<span class="hljs-number">3</span>))
[{<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: Mtendere Village was inspired by...&#x27;</span>},
 {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: Lily James cannot fight the music...&#x27;</span>},
 {<span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My text: &quot;I\\&#x27;d love to help kickstart...&#x27;</span>}]`}}),ys=new M({}),ks=new M({}),Es=new T({props:{code:`from datasets import load_dataset
from transformers import AutoTokenizer
dataset = load_dataset("mc4", "en", streaming=True, split="train")
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-uncased')
def encode(examples):
    return tokenizer(examples['text'], truncation=True, padding='max_length')
dataset = dataset.map(encode, batched=True, remove_columns=["text", "timestamp", "url"])
next(iter(dataset))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;mc4&quot;</span>, <span class="hljs-string">&quot;en&quot;</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&#x27;distilbert-base-uncased&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">encode</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(examples[<span class="hljs-string">&#x27;text&#x27;</span>], truncation=<span class="hljs-literal">True</span>, padding=<span class="hljs-string">&#x27;max_length&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(encode, batched=<span class="hljs-literal">True</span>, remove_columns=[<span class="hljs-string">&quot;text&quot;</span>, <span class="hljs-string">&quot;timestamp&quot;</span>, <span class="hljs-string">&quot;url&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(dataset))
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: <span class="hljs-number">101</span>, <span class="hljs-number">8466</span>, <span class="hljs-number">1018</span>, <span class="hljs-number">1010</span>, <span class="hljs-number">4029</span>, <span class="hljs-number">2475</span>, <span class="hljs-number">2062</span>, <span class="hljs-number">18558</span>, <span class="hljs-number">3100</span>, <span class="hljs-number">2061</span>, ...,<span class="hljs-number">1106</span>, <span class="hljs-number">3739</span>, <span class="hljs-number">102</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>, <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>]}`}}),He=new St({props:{$$slots:{default:[Lh]},$$scope:{ctx:C}}}),Ds=new M({}),As=new T({props:{code:`from datasets import load_dataset
dataset = load_dataset('oscar', 'unshuffled_deduplicated_en', streaming=True, split='train')
start_with_ar = dataset.filter(lambda example: example['text'].startswith('Ar'))
next(iter(start_with_ar))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&#x27;oscar&#x27;</span>, <span class="hljs-string">&#x27;unshuffled_deduplicated_en&#x27;</span>, streaming=<span class="hljs-literal">True</span>, split=<span class="hljs-string">&#x27;train&#x27;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>start_with_ar = dataset.<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> example: example[<span class="hljs-string">&#x27;text&#x27;</span>].startswith(<span class="hljs-string">&#x27;Ar&#x27;</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">next</span>(<span class="hljs-built_in">iter</span>(start_with_ar))
{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">4</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Are you looking for Number the Stars (Essential Modern Classics)?...&#x27;</span>}`}}),Is=new T({props:{code:`even_dataset = dataset.filter(lambda example, idx: idx % 2 == 0, with_indices=True)
list(even_dataset.take(3))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>even_dataset = dataset.<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> example, idx: idx % <span class="hljs-number">2</span> == <span class="hljs-number">0</span>, with_indices=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">list</span>(even_dataset.take(<span class="hljs-number">3</span>))
[{<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Mtendere Village was inspired by the vision of Chief Napoleon Dzombe, ...&#x27;</span>},
 {<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">2</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;&quot;I\\&#x27;d love to help kickstart continued development! And 0 EUR/month...&#x27;</span>},
 {<span class="hljs-string">&#x27;id&#x27;</span>: <span class="hljs-number">4</span>, <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;Are you looking for Number the Stars (Essential Modern Classics)? Normally, ...&#x27;</span>}]`}}),Ts=new M({}),Je=new Sh({props:{pytorch:!0,tensorflow:!1,jax:!1,$$slots:{pytorch:[Oh]},$$scope:{ctx:C}}}),{c(){d=n("meta"),w=c(),m=n("h1"),y=n("a"),k=n("span"),_(g.$$.fragment),E=c(),u=n("span"),D=t("Stream"),A=c(),S=n("p"),z=t(`Dataset streaming lets you work with a dataset without downloading it.
The data is streamed as you iterate over the dataset.
This is especially helpful when:`),P=c(),q=n("ul"),I=n("li"),Q=t("You don\u2019t want to wait for an extremely large dataset to download."),Cs=c(),ge=n("li"),zs=t("The dataset size exceeds the amount of available disk space on your computer."),$n=c(),ka=n("li"),wn=t("You want to quickly explore just a few samples of a dataset."),Pt=c(),X=n("div"),Ns=n("img"),yn=c(),Ls=n("img"),qt=c(),R=n("p"),kn=t("For example, the English split of the "),Xe=n("a"),En=t("oscar-corpus/OSCAR-2201"),Dn=t(" dataset is 1.2 terabytes, but you can use it instantly with streaming. Stream a dataset by setting "),Ea=n("code"),An=t("streaming=True"),In=t(" in "),Ms=n("a"),Tn=t("load_dataset()"),Sn=t(" as shown below:"),Ct=c(),_(Ze.$$.fragment),zt=c(),Os=n("p"),Pn=t(`Dataset streaming also lets you work with a dataset made of local files without doing any conversion.
In this case, the data is streamed from the local files as you iterate over the dataset.
This is especially helpful when:`),Nt=c(),U=n("ul"),Da=n("li"),qn=t("You don\u2019t want to wait for an extremely large local dataset to be converted to Arrow."),Cn=c(),Aa=n("li"),zn=t("The converted files size would exceed the amount of available disk space on your computer."),Nn=c(),Ia=n("li"),Ln=t("You want to quickly explore just a few samples of a dataset."),Lt=c(),_e=n("p"),Mn=t("For example, you can stream a local dataset of hundreds of ompressed JSONL files like "),es=n("a"),On=t("oscar-corpus/OSCAR-2201"),Rn=t(" to use it instantly:"),Mt=c(),_(ss.$$.fragment),Ot=c(),B=n("p"),Fn=t("Loading a dataset in streaming mode creates a new dataset type instance (instead of the classic "),Rs=n("a"),Yn=t("Dataset"),Vn=t(" object), known as an "),Fs=n("a"),Hn=t("IterableDataset"),Un=t(`.
This special type of dataset has its own set of processing methods shown below.`),Rt=c(),_(ve.$$.fragment),Ft=c(),Z=n("h2"),je=n("a"),Ta=n("span"),_(as.$$.fragment),Bn=c(),Sa=n("span"),Gn=t("Shuffle"),Yt=c(),F=n("p"),Jn=t("Like a regular "),Ys=n("a"),Wn=t("Dataset"),Kn=t(" object, you can also shuffle a "),Vs=n("a"),Qn=t("IterableDataset"),Xn=t(" with "),Hs=n("a"),Zn=t("IterableDataset.shuffle()"),er=t("."),Vt=c(),Y=n("p"),sr=t("The "),Pa=n("code"),ar=t("buffer_size"),tr=t(" argument controls the size of the buffer to randomly sample examples from. Let\u2019s say your dataset has one million examples, and you set the "),qa=n("code"),lr=t("buffer_size"),nr=t(" to ten thousand. "),Us=n("a"),rr=t("IterableDataset.shuffle()"),or=t(" will randomly select examples from the first ten thousand examples in the buffer. Selected examples in the buffer are replaced with new examples. By default, the buffer size is 1,000."),Ht=c(),_(ts.$$.fragment),Ut=c(),_(be.$$.fragment),Bt=c(),ee=n("h2"),xe=n("a"),Ca=n("span"),_(ls.$$.fragment),pr=c(),za=n("span"),ir=t("Reshuffle"),Gt=c(),$e=n("p"),hr=t("Sometimes you may want to reshuffle the dataset after each epoch. This will require you to set a different seed for each epoch. Use "),Na=n("code"),cr=t("IterableDataset.set_epoch()"),fr=t(" in between epochs to tell the dataset what epoch you\u2019re on."),Jt=c(),we=n("p"),dr=t("Your seed effectively becomes: "),La=n("code"),mr=t("initial seed + current epoch"),ur=t("."),Wt=c(),_(ns.$$.fragment),Kt=c(),se=n("h2"),ye=n("a"),Ma=n("span"),_(rs.$$.fragment),gr=c(),Oa=n("span"),_r=t("Split dataset"),Qt=c(),Bs=n("p"),vr=t("You can split your dataset one of two ways:"),Xt=c(),Gs=n("ul"),ke=n("li"),Js=n("a"),jr=t("IterableDataset.take()"),br=t(" returns the first "),Ra=n("code"),xr=t("n"),$r=t(" examples in a dataset:"),Zt=c(),_(os.$$.fragment),el=c(),Ws=n("ul"),Ee=n("li"),Ks=n("a"),wr=t("IterableDataset.skip()"),yr=t(" omits the first "),Fa=n("code"),kr=t("n"),Er=t(" examples in a dataset and returns the remaining examples:"),sl=c(),_(ps.$$.fragment),al=c(),_(De.$$.fragment),tl=c(),Qs=n("a"),ll=c(),ae=n("h2"),Ae=n("a"),Ya=n("span"),_(is.$$.fragment),Dr=c(),Va=n("span"),Ar=t("Interleave"),nl=c(),te=n("p"),Xs=n("a"),Ir=t("interleave_datasets()"),Tr=t(" can combine an "),Zs=n("a"),Sr=t("IterableDataset"),Pr=t(" with other datasets. The combined dataset returns alternating examples from each of the original datasets."),rl=c(),_(hs.$$.fragment),ol=c(),Ie=n("p"),qr=t("Define sampling probabilities from each of the original datasets for more control over how each of them are sampled and combined. Set the "),Ha=n("code"),Cr=t("probabilities"),zr=t(" argument with your desired sampling probabilities:"),pl=c(),_(cs.$$.fragment),il=c(),G=n("p"),Nr=t("Around 80% of the final dataset is made of the "),Ua=n("code"),Lr=t("en_dataset"),Mr=t(", and 20% of the "),Ba=n("code"),Or=t("fr_dataset"),Rr=t("."),hl=c(),L=n("p"),Fr=t("You can also specify the "),Ga=n("code"),Yr=t("stopping_strategy"),Vr=t(". The default strategy, "),Ja=n("code"),Hr=t("first_exhausted"),Ur=t(`, is a subsampling strategy, i.e the dataset construction is stopped as soon one of the dataset runs out of samples.
You can specify `),Wa=n("code"),Br=t("stopping_strategy=all_exhausted"),Gr=t(` to execute an oversampling strategy. In this case, the dataset construction is stopped as soon as every samples in every dataset has been added at least once. In practice, it means that if a dataset is exhausted, it will return to the beginning of this dataset until the stop criterion has been reached.
Note that if no sampling probabilities are specified, the new dataset will have `),Ka=n("code"),Jr=t("max_length_datasets*nb_dataset samples"),Wr=t("."),cl=c(),le=n("h2"),Te=n("a"),Qa=n("span"),_(fs.$$.fragment),Kr=c(),Xa=n("span"),Qr=t("Rename, remove, and cast"),fl=c(),ea=n("p"),Xr=t("The following methods allow you to modify the columns of a dataset. These methods are useful for renaming or removing columns and changing columns to a new set of features."),dl=c(),ne=n("h3"),Se=n("a"),Za=n("span"),_(ds.$$.fragment),Zr=c(),et=n("span"),eo=t("Rename"),ml=c(),Pe=n("p"),so=t("Use "),sa=n("a"),ao=t("IterableDataset.rename_column()"),to=t(" when you need to rename a column in your dataset. Features associated with the original column are actually moved under the new column name, instead of just replacing the original column in-place."),ul=c(),qe=n("p"),lo=t("Provide "),aa=n("a"),no=t("IterableDataset.rename_column()"),ro=t(" with the name of the original column, and the new column name:"),gl=c(),_(ms.$$.fragment),_l=c(),re=n("h3"),Ce=n("a"),st=n("span"),_(us.$$.fragment),oo=c(),at=n("span"),po=t("Remove"),vl=c(),ze=n("p"),io=t("When you need to remove one or more columns, give "),ta=n("a"),ho=t("IterableDataset.remove_columns()"),co=t(" the name of the column to remove. Remove more than one column by providing a list of column names:"),jl=c(),_(gs.$$.fragment),bl=c(),oe=n("h3"),Ne=n("a"),tt=n("span"),_(_s.$$.fragment),fo=c(),lt=n("span"),mo=t("Cast"),xl=c(),O=n("p"),la=n("a"),uo=t("IterableDataset.cast()"),go=t(" changes the feature type of one or more columns. This method takes your new "),nt=n("code"),_o=t("Features"),vo=t(" as its argument. The following sample code shows how to change the feature types of "),rt=n("code"),jo=t("ClassLabel"),bo=t(" and "),ot=n("code"),xo=t("Value"),$o=t(":"),$l=c(),_(vs.$$.fragment),wl=c(),_(Le.$$.fragment),yl=c(),Me=n("p"),wo=t("Use "),na=n("a"),yo=t("IterableDataset.cast_column()"),ko=t(" to change the feature type of just one column. Pass the column name and its new feature type as arguments:"),kl=c(),_(js.$$.fragment),El=c(),pe=n("h2"),Oe=n("a"),pt=n("span"),_(bs.$$.fragment),Eo=c(),it=n("span"),Do=t("Map"),Dl=c(),N=n("p"),Ao=t("Similar to the "),ra=n("a"),Io=t("Dataset.map()"),To=t(" function for a regular "),oa=n("a"),So=t("Dataset"),Po=t(", \u{1F917}  Datasets features "),pa=n("a"),qo=t("IterableDataset.map()"),Co=t(" for processing an "),ia=n("a"),zo=t("IterableDataset"),No=t(`.
`),ha=n("a"),Lo=t("IterableDataset.map()"),Mo=t(" applies processing on-the-fly when examples are streamed."),Al=c(),ca=n("p"),Oo=t("It allows you to apply a processing function to each example in a dataset, independently or in batches. This function can even create new rows and columns."),Il=c(),J=n("p"),Ro=t("The following example demonstrates how to tokenize a "),fa=n("a"),Fo=t("IterableDataset"),Yo=t(". The function needs to accept and output a "),ht=n("code"),Vo=t("dict"),Ho=t(":"),Tl=c(),_(xs.$$.fragment),Sl=c(),Re=n("p"),Uo=t("Next, apply this function to the dataset with "),da=n("a"),Bo=t("IterableDataset.map()"),Go=t(":"),Pl=c(),_($s.$$.fragment),ql=c(),Fe=n("p"),Jo=t("Let\u2019s take a look at another example, except this time, you will remove a column with "),ma=n("a"),Wo=t("IterableDataset.map()"),Ko=t(". When you remove a column, it is only removed after the example has been provided to the mapped function. This allows the mapped function to use the content of the columns before they are removed."),Cl=c(),W=n("p"),Qo=t("Specify the column to remove with the "),ct=n("code"),Xo=t("remove_columns"),Zo=t(" argument in "),ua=n("a"),ep=t("IterableDataset.map()"),sp=t(":"),zl=c(),_(ws.$$.fragment),Nl=c(),ie=n("h3"),Ye=n("a"),ft=n("span"),_(ys.$$.fragment),ap=c(),dt=n("span"),tp=t("Batch processing"),Ll=c(),H=n("p"),ga=n("a"),lp=t("IterableDataset.map()"),np=t(" also supports working with batches of examples. Operate on batches by setting "),mt=n("code"),rp=t("batched=True"),op=t(". The default batch size is 1000, but you can adjust it with the "),ut=n("code"),pp=t("batch_size"),ip=t(" argument. This opens the door to many interesting applications such as tokenization, splitting long sentences into shorter chunks, and data augmentation."),Ml=c(),he=n("h4"),Ve=n("a"),gt=n("span"),_(ks.$$.fragment),hp=c(),_t=n("span"),cp=t("Tokenization"),Ol=c(),_(Es.$$.fragment),Rl=c(),_(He.$$.fragment),Fl=c(),ce=n("h3"),Ue=n("a"),vt=n("span"),_(Ds.$$.fragment),fp=c(),jt=n("span"),dp=t("Filter"),Yl=c(),Be=n("p"),mp=t("You can filter rows in the dataset based on a predicate function using "),_a=n("a"),up=t("Dataset.filter()"),gp=t(". It returns rows that match a specified condition:"),Vl=c(),_(As.$$.fragment),Hl=c(),fe=n("p"),va=n("a"),_p=t("Dataset.filter()"),vp=t(" can also filter by indices if you set "),bt=n("code"),jp=t("with_indices=True"),bp=t(":"),Ul=c(),_(Is.$$.fragment),Bl=c(),de=n("h2"),Ge=n("a"),xt=n("span"),_(Ts.$$.fragment),xp=c(),$t=n("span"),$p=t("Stream in a training loop"),Gl=c(),Ss=n("p"),ja=n("a"),wp=t("IterableDataset"),yp=t(" can be integrated into a training loop. First, shuffle the dataset:"),Jl=c(),_(Je.$$.fragment),this.h()},l(e){const p=Ah('[data-svelte="svelte-1phssyn"]',document.head);d=r(p,"META",{name:!0,content:!0}),p.forEach(a),w=f(e),m=r(e,"H1",{class:!0});var Ps=o(m);y=r(Ps,"A",{id:!0,class:!0,href:!0});var wt=o(y);k=r(wt,"SPAN",{});var yt=o(k);v(g.$$.fragment,yt),yt.forEach(a),wt.forEach(a),E=f(Ps),u=r(Ps,"SPAN",{});var kt=o(u);D=l(kt,"Stream"),kt.forEach(a),Ps.forEach(a),A=f(e),S=r(e,"P",{});var Et=o(S);z=l(Et,`Dataset streaming lets you work with a dataset without downloading it.
The data is streamed as you iterate over the dataset.
This is especially helpful when:`),Et.forEach(a),P=f(e),q=r(e,"UL",{});var me=o(q);I=r(me,"LI",{});var Ap=o(I);Q=l(Ap,"You don\u2019t want to wait for an extremely large dataset to download."),Ap.forEach(a),Cs=f(me),ge=r(me,"LI",{});var Ip=o(ge);zs=l(Ip,"The dataset size exceeds the amount of available disk space on your computer."),Ip.forEach(a),$n=f(me),ka=r(me,"LI",{});var Tp=o(ka);wn=l(Tp,"You want to quickly explore just a few samples of a dataset."),Tp.forEach(a),me.forEach(a),Pt=f(e),X=r(e,"DIV",{class:!0});var Kl=o(X);Ns=r(Kl,"IMG",{class:!0,src:!0}),yn=f(Kl),Ls=r(Kl,"IMG",{class:!0,src:!0}),Kl.forEach(a),qt=f(e),R=r(e,"P",{});var We=o(R);kn=l(We,"For example, the English split of the "),Xe=r(We,"A",{href:!0,rel:!0});var Sp=o(Xe);En=l(Sp,"oscar-corpus/OSCAR-2201"),Sp.forEach(a),Dn=l(We," dataset is 1.2 terabytes, but you can use it instantly with streaming. Stream a dataset by setting "),Ea=r(We,"CODE",{});var Pp=o(Ea);An=l(Pp,"streaming=True"),Pp.forEach(a),In=l(We," in "),Ms=r(We,"A",{href:!0});var qp=o(Ms);Tn=l(qp,"load_dataset()"),qp.forEach(a),Sn=l(We," as shown below:"),We.forEach(a),Ct=f(e),v(Ze.$$.fragment,e),zt=f(e),Os=r(e,"P",{});var Cp=o(Os);Pn=l(Cp,`Dataset streaming also lets you work with a dataset made of local files without doing any conversion.
In this case, the data is streamed from the local files as you iterate over the dataset.
This is especially helpful when:`),Cp.forEach(a),Nt=f(e),U=r(e,"UL",{});var ba=o(U);Da=r(ba,"LI",{});var zp=o(Da);qn=l(zp,"You don\u2019t want to wait for an extremely large local dataset to be converted to Arrow."),zp.forEach(a),Cn=f(ba),Aa=r(ba,"LI",{});var Np=o(Aa);zn=l(Np,"The converted files size would exceed the amount of available disk space on your computer."),Np.forEach(a),Nn=f(ba),Ia=r(ba,"LI",{});var Lp=o(Ia);Ln=l(Lp,"You want to quickly explore just a few samples of a dataset."),Lp.forEach(a),ba.forEach(a),Lt=f(e),_e=r(e,"P",{});var Ql=o(_e);Mn=l(Ql,"For example, you can stream a local dataset of hundreds of ompressed JSONL files like "),es=r(Ql,"A",{href:!0,rel:!0});var Mp=o(es);On=l(Mp,"oscar-corpus/OSCAR-2201"),Mp.forEach(a),Rn=l(Ql," to use it instantly:"),Ql.forEach(a),Mt=f(e),v(ss.$$.fragment,e),Ot=f(e),B=r(e,"P",{});var xa=o(B);Fn=l(xa,"Loading a dataset in streaming mode creates a new dataset type instance (instead of the classic "),Rs=r(xa,"A",{href:!0});var Op=o(Rs);Yn=l(Op,"Dataset"),Op.forEach(a),Vn=l(xa," object), known as an "),Fs=r(xa,"A",{href:!0});var Rp=o(Fs);Hn=l(Rp,"IterableDataset"),Rp.forEach(a),Un=l(xa,`.
This special type of dataset has its own set of processing methods shown below.`),xa.forEach(a),Rt=f(e),v(ve.$$.fragment,e),Ft=f(e),Z=r(e,"H2",{class:!0});var Xl=o(Z);je=r(Xl,"A",{id:!0,class:!0,href:!0});var Fp=o(je);Ta=r(Fp,"SPAN",{});var Yp=o(Ta);v(as.$$.fragment,Yp),Yp.forEach(a),Fp.forEach(a),Bn=f(Xl),Sa=r(Xl,"SPAN",{});var Vp=o(Sa);Gn=l(Vp,"Shuffle"),Vp.forEach(a),Xl.forEach(a),Yt=f(e),F=r(e,"P",{});var Ke=o(F);Jn=l(Ke,"Like a regular "),Ys=r(Ke,"A",{href:!0});var Hp=o(Ys);Wn=l(Hp,"Dataset"),Hp.forEach(a),Kn=l(Ke," object, you can also shuffle a "),Vs=r(Ke,"A",{href:!0});var Up=o(Vs);Qn=l(Up,"IterableDataset"),Up.forEach(a),Xn=l(Ke," with "),Hs=r(Ke,"A",{href:!0});var Bp=o(Hs);Zn=l(Bp,"IterableDataset.shuffle()"),Bp.forEach(a),er=l(Ke,"."),Ke.forEach(a),Vt=f(e),Y=r(e,"P",{});var Qe=o(Y);sr=l(Qe,"The "),Pa=r(Qe,"CODE",{});var Gp=o(Pa);ar=l(Gp,"buffer_size"),Gp.forEach(a),tr=l(Qe," argument controls the size of the buffer to randomly sample examples from. Let\u2019s say your dataset has one million examples, and you set the "),qa=r(Qe,"CODE",{});var Jp=o(qa);lr=l(Jp,"buffer_size"),Jp.forEach(a),nr=l(Qe," to ten thousand. "),Us=r(Qe,"A",{href:!0});var Wp=o(Us);rr=l(Wp,"IterableDataset.shuffle()"),Wp.forEach(a),or=l(Qe," will randomly select examples from the first ten thousand examples in the buffer. Selected examples in the buffer are replaced with new examples. By default, the buffer size is 1,000."),Qe.forEach(a),Ht=f(e),v(ts.$$.fragment,e),Ut=f(e),v(be.$$.fragment,e),Bt=f(e),ee=r(e,"H2",{class:!0});var Zl=o(ee);xe=r(Zl,"A",{id:!0,class:!0,href:!0});var Kp=o(xe);Ca=r(Kp,"SPAN",{});var Qp=o(Ca);v(ls.$$.fragment,Qp),Qp.forEach(a),Kp.forEach(a),pr=f(Zl),za=r(Zl,"SPAN",{});var Xp=o(za);ir=l(Xp,"Reshuffle"),Xp.forEach(a),Zl.forEach(a),Gt=f(e),$e=r(e,"P",{});var en=o($e);hr=l(en,"Sometimes you may want to reshuffle the dataset after each epoch. This will require you to set a different seed for each epoch. Use "),Na=r(en,"CODE",{});var Zp=o(Na);cr=l(Zp,"IterableDataset.set_epoch()"),Zp.forEach(a),fr=l(en," in between epochs to tell the dataset what epoch you\u2019re on."),en.forEach(a),Jt=f(e),we=r(e,"P",{});var sn=o(we);dr=l(sn,"Your seed effectively becomes: "),La=r(sn,"CODE",{});var ei=o(La);mr=l(ei,"initial seed + current epoch"),ei.forEach(a),ur=l(sn,"."),sn.forEach(a),Wt=f(e),v(ns.$$.fragment,e),Kt=f(e),se=r(e,"H2",{class:!0});var an=o(se);ye=r(an,"A",{id:!0,class:!0,href:!0});var si=o(ye);Ma=r(si,"SPAN",{});var ai=o(Ma);v(rs.$$.fragment,ai),ai.forEach(a),si.forEach(a),gr=f(an),Oa=r(an,"SPAN",{});var ti=o(Oa);_r=l(ti,"Split dataset"),ti.forEach(a),an.forEach(a),Qt=f(e),Bs=r(e,"P",{});var li=o(Bs);vr=l(li,"You can split your dataset one of two ways:"),li.forEach(a),Xt=f(e),Gs=r(e,"UL",{});var ni=o(Gs);ke=r(ni,"LI",{});var Dt=o(ke);Js=r(Dt,"A",{href:!0});var ri=o(Js);jr=l(ri,"IterableDataset.take()"),ri.forEach(a),br=l(Dt," returns the first "),Ra=r(Dt,"CODE",{});var oi=o(Ra);xr=l(oi,"n"),oi.forEach(a),$r=l(Dt," examples in a dataset:"),Dt.forEach(a),ni.forEach(a),Zt=f(e),v(os.$$.fragment,e),el=f(e),Ws=r(e,"UL",{});var pi=o(Ws);Ee=r(pi,"LI",{});var At=o(Ee);Ks=r(At,"A",{href:!0});var ii=o(Ks);wr=l(ii,"IterableDataset.skip()"),ii.forEach(a),yr=l(At," omits the first "),Fa=r(At,"CODE",{});var hi=o(Fa);kr=l(hi,"n"),hi.forEach(a),Er=l(At," examples in a dataset and returns the remaining examples:"),At.forEach(a),pi.forEach(a),sl=f(e),v(ps.$$.fragment,e),al=f(e),v(De.$$.fragment,e),tl=f(e),Qs=r(e,"A",{id:!0}),o(Qs).forEach(a),ll=f(e),ae=r(e,"H2",{class:!0});var tn=o(ae);Ae=r(tn,"A",{id:!0,class:!0,href:!0});var ci=o(Ae);Ya=r(ci,"SPAN",{});var fi=o(Ya);v(is.$$.fragment,fi),fi.forEach(a),ci.forEach(a),Dr=f(tn),Va=r(tn,"SPAN",{});var di=o(Va);Ar=l(di,"Interleave"),di.forEach(a),tn.forEach(a),nl=f(e),te=r(e,"P",{});var It=o(te);Xs=r(It,"A",{href:!0});var mi=o(Xs);Ir=l(mi,"interleave_datasets()"),mi.forEach(a),Tr=l(It," can combine an "),Zs=r(It,"A",{href:!0});var ui=o(Zs);Sr=l(ui,"IterableDataset"),ui.forEach(a),Pr=l(It," with other datasets. The combined dataset returns alternating examples from each of the original datasets."),It.forEach(a),rl=f(e),v(hs.$$.fragment,e),ol=f(e),Ie=r(e,"P",{});var ln=o(Ie);qr=l(ln,"Define sampling probabilities from each of the original datasets for more control over how each of them are sampled and combined. Set the "),Ha=r(ln,"CODE",{});var gi=o(Ha);Cr=l(gi,"probabilities"),gi.forEach(a),zr=l(ln," argument with your desired sampling probabilities:"),ln.forEach(a),pl=f(e),v(cs.$$.fragment,e),il=f(e),G=r(e,"P",{});var $a=o(G);Nr=l($a,"Around 80% of the final dataset is made of the "),Ua=r($a,"CODE",{});var _i=o(Ua);Lr=l(_i,"en_dataset"),_i.forEach(a),Mr=l($a,", and 20% of the "),Ba=r($a,"CODE",{});var vi=o(Ba);Or=l(vi,"fr_dataset"),vi.forEach(a),Rr=l($a,"."),$a.forEach(a),hl=f(e),L=r(e,"P",{});var K=o(L);Fr=l(K,"You can also specify the "),Ga=r(K,"CODE",{});var ji=o(Ga);Yr=l(ji,"stopping_strategy"),ji.forEach(a),Vr=l(K,". The default strategy, "),Ja=r(K,"CODE",{});var bi=o(Ja);Hr=l(bi,"first_exhausted"),bi.forEach(a),Ur=l(K,`, is a subsampling strategy, i.e the dataset construction is stopped as soon one of the dataset runs out of samples.
You can specify `),Wa=r(K,"CODE",{});var xi=o(Wa);Br=l(xi,"stopping_strategy=all_exhausted"),xi.forEach(a),Gr=l(K,` to execute an oversampling strategy. In this case, the dataset construction is stopped as soon as every samples in every dataset has been added at least once. In practice, it means that if a dataset is exhausted, it will return to the beginning of this dataset until the stop criterion has been reached.
Note that if no sampling probabilities are specified, the new dataset will have `),Ka=r(K,"CODE",{});var $i=o(Ka);Jr=l($i,"max_length_datasets*nb_dataset samples"),$i.forEach(a),Wr=l(K,"."),K.forEach(a),cl=f(e),le=r(e,"H2",{class:!0});var nn=o(le);Te=r(nn,"A",{id:!0,class:!0,href:!0});var wi=o(Te);Qa=r(wi,"SPAN",{});var yi=o(Qa);v(fs.$$.fragment,yi),yi.forEach(a),wi.forEach(a),Kr=f(nn),Xa=r(nn,"SPAN",{});var ki=o(Xa);Qr=l(ki,"Rename, remove, and cast"),ki.forEach(a),nn.forEach(a),fl=f(e),ea=r(e,"P",{});var Ei=o(ea);Xr=l(Ei,"The following methods allow you to modify the columns of a dataset. These methods are useful for renaming or removing columns and changing columns to a new set of features."),Ei.forEach(a),dl=f(e),ne=r(e,"H3",{class:!0});var rn=o(ne);Se=r(rn,"A",{id:!0,class:!0,href:!0});var Di=o(Se);Za=r(Di,"SPAN",{});var Ai=o(Za);v(ds.$$.fragment,Ai),Ai.forEach(a),Di.forEach(a),Zr=f(rn),et=r(rn,"SPAN",{});var Ii=o(et);eo=l(Ii,"Rename"),Ii.forEach(a),rn.forEach(a),ml=f(e),Pe=r(e,"P",{});var on=o(Pe);so=l(on,"Use "),sa=r(on,"A",{href:!0});var Ti=o(sa);ao=l(Ti,"IterableDataset.rename_column()"),Ti.forEach(a),to=l(on," when you need to rename a column in your dataset. Features associated with the original column are actually moved under the new column name, instead of just replacing the original column in-place."),on.forEach(a),ul=f(e),qe=r(e,"P",{});var pn=o(qe);lo=l(pn,"Provide "),aa=r(pn,"A",{href:!0});var Si=o(aa);no=l(Si,"IterableDataset.rename_column()"),Si.forEach(a),ro=l(pn," with the name of the original column, and the new column name:"),pn.forEach(a),gl=f(e),v(ms.$$.fragment,e),_l=f(e),re=r(e,"H3",{class:!0});var hn=o(re);Ce=r(hn,"A",{id:!0,class:!0,href:!0});var Pi=o(Ce);st=r(Pi,"SPAN",{});var qi=o(st);v(us.$$.fragment,qi),qi.forEach(a),Pi.forEach(a),oo=f(hn),at=r(hn,"SPAN",{});var Ci=o(at);po=l(Ci,"Remove"),Ci.forEach(a),hn.forEach(a),vl=f(e),ze=r(e,"P",{});var cn=o(ze);io=l(cn,"When you need to remove one or more columns, give "),ta=r(cn,"A",{href:!0});var zi=o(ta);ho=l(zi,"IterableDataset.remove_columns()"),zi.forEach(a),co=l(cn," the name of the column to remove. Remove more than one column by providing a list of column names:"),cn.forEach(a),jl=f(e),v(gs.$$.fragment,e),bl=f(e),oe=r(e,"H3",{class:!0});var fn=o(oe);Ne=r(fn,"A",{id:!0,class:!0,href:!0});var Ni=o(Ne);tt=r(Ni,"SPAN",{});var Li=o(tt);v(_s.$$.fragment,Li),Li.forEach(a),Ni.forEach(a),fo=f(fn),lt=r(fn,"SPAN",{});var Mi=o(lt);mo=l(Mi,"Cast"),Mi.forEach(a),fn.forEach(a),xl=f(e),O=r(e,"P",{});var ue=o(O);la=r(ue,"A",{href:!0});var Oi=o(la);uo=l(Oi,"IterableDataset.cast()"),Oi.forEach(a),go=l(ue," changes the feature type of one or more columns. This method takes your new "),nt=r(ue,"CODE",{});var Ri=o(nt);_o=l(Ri,"Features"),Ri.forEach(a),vo=l(ue," as its argument. The following sample code shows how to change the feature types of "),rt=r(ue,"CODE",{});var Fi=o(rt);jo=l(Fi,"ClassLabel"),Fi.forEach(a),bo=l(ue," and "),ot=r(ue,"CODE",{});var Yi=o(ot);xo=l(Yi,"Value"),Yi.forEach(a),$o=l(ue,":"),ue.forEach(a),$l=f(e),v(vs.$$.fragment,e),wl=f(e),v(Le.$$.fragment,e),yl=f(e),Me=r(e,"P",{});var dn=o(Me);wo=l(dn,"Use "),na=r(dn,"A",{href:!0});var Vi=o(na);yo=l(Vi,"IterableDataset.cast_column()"),Vi.forEach(a),ko=l(dn," to change the feature type of just one column. Pass the column name and its new feature type as arguments:"),dn.forEach(a),kl=f(e),v(js.$$.fragment,e),El=f(e),pe=r(e,"H2",{class:!0});var mn=o(pe);Oe=r(mn,"A",{id:!0,class:!0,href:!0});var Hi=o(Oe);pt=r(Hi,"SPAN",{});var Ui=o(pt);v(bs.$$.fragment,Ui),Ui.forEach(a),Hi.forEach(a),Eo=f(mn),it=r(mn,"SPAN",{});var Bi=o(it);Do=l(Bi,"Map"),Bi.forEach(a),mn.forEach(a),Dl=f(e),N=r(e,"P",{});var V=o(N);Ao=l(V,"Similar to the "),ra=r(V,"A",{href:!0});var Gi=o(ra);Io=l(Gi,"Dataset.map()"),Gi.forEach(a),To=l(V," function for a regular "),oa=r(V,"A",{href:!0});var Ji=o(oa);So=l(Ji,"Dataset"),Ji.forEach(a),Po=l(V,", \u{1F917}  Datasets features "),pa=r(V,"A",{href:!0});var Wi=o(pa);qo=l(Wi,"IterableDataset.map()"),Wi.forEach(a),Co=l(V," for processing an "),ia=r(V,"A",{href:!0});var Ki=o(ia);zo=l(Ki,"IterableDataset"),Ki.forEach(a),No=l(V,`.
`),ha=r(V,"A",{href:!0});var Qi=o(ha);Lo=l(Qi,"IterableDataset.map()"),Qi.forEach(a),Mo=l(V," applies processing on-the-fly when examples are streamed."),V.forEach(a),Al=f(e),ca=r(e,"P",{});var Xi=o(ca);Oo=l(Xi,"It allows you to apply a processing function to each example in a dataset, independently or in batches. This function can even create new rows and columns."),Xi.forEach(a),Il=f(e),J=r(e,"P",{});var wa=o(J);Ro=l(wa,"The following example demonstrates how to tokenize a "),fa=r(wa,"A",{href:!0});var Zi=o(fa);Fo=l(Zi,"IterableDataset"),Zi.forEach(a),Yo=l(wa,". The function needs to accept and output a "),ht=r(wa,"CODE",{});var eh=o(ht);Vo=l(eh,"dict"),eh.forEach(a),Ho=l(wa,":"),wa.forEach(a),Tl=f(e),v(xs.$$.fragment,e),Sl=f(e),Re=r(e,"P",{});var un=o(Re);Uo=l(un,"Next, apply this function to the dataset with "),da=r(un,"A",{href:!0});var sh=o(da);Bo=l(sh,"IterableDataset.map()"),sh.forEach(a),Go=l(un,":"),un.forEach(a),Pl=f(e),v($s.$$.fragment,e),ql=f(e),Fe=r(e,"P",{});var gn=o(Fe);Jo=l(gn,"Let\u2019s take a look at another example, except this time, you will remove a column with "),ma=r(gn,"A",{href:!0});var ah=o(ma);Wo=l(ah,"IterableDataset.map()"),ah.forEach(a),Ko=l(gn,". When you remove a column, it is only removed after the example has been provided to the mapped function. This allows the mapped function to use the content of the columns before they are removed."),gn.forEach(a),Cl=f(e),W=r(e,"P",{});var ya=o(W);Qo=l(ya,"Specify the column to remove with the "),ct=r(ya,"CODE",{});var th=o(ct);Xo=l(th,"remove_columns"),th.forEach(a),Zo=l(ya," argument in "),ua=r(ya,"A",{href:!0});var lh=o(ua);ep=l(lh,"IterableDataset.map()"),lh.forEach(a),sp=l(ya,":"),ya.forEach(a),zl=f(e),v(ws.$$.fragment,e),Nl=f(e),ie=r(e,"H3",{class:!0});var _n=o(ie);Ye=r(_n,"A",{id:!0,class:!0,href:!0});var nh=o(Ye);ft=r(nh,"SPAN",{});var rh=o(ft);v(ys.$$.fragment,rh),rh.forEach(a),nh.forEach(a),ap=f(_n),dt=r(_n,"SPAN",{});var oh=o(dt);tp=l(oh,"Batch processing"),oh.forEach(a),_n.forEach(a),Ll=f(e),H=r(e,"P",{});var qs=o(H);ga=r(qs,"A",{href:!0});var ph=o(ga);lp=l(ph,"IterableDataset.map()"),ph.forEach(a),np=l(qs," also supports working with batches of examples. Operate on batches by setting "),mt=r(qs,"CODE",{});var ih=o(mt);rp=l(ih,"batched=True"),ih.forEach(a),op=l(qs,". The default batch size is 1000, but you can adjust it with the "),ut=r(qs,"CODE",{});var hh=o(ut);pp=l(hh,"batch_size"),hh.forEach(a),ip=l(qs," argument. This opens the door to many interesting applications such as tokenization, splitting long sentences into shorter chunks, and data augmentation."),qs.forEach(a),Ml=f(e),he=r(e,"H4",{class:!0});var vn=o(he);Ve=r(vn,"A",{id:!0,class:!0,href:!0});var ch=o(Ve);gt=r(ch,"SPAN",{});var fh=o(gt);v(ks.$$.fragment,fh),fh.forEach(a),ch.forEach(a),hp=f(vn),_t=r(vn,"SPAN",{});var dh=o(_t);cp=l(dh,"Tokenization"),dh.forEach(a),vn.forEach(a),Ol=f(e),v(Es.$$.fragment,e),Rl=f(e),v(He.$$.fragment,e),Fl=f(e),ce=r(e,"H3",{class:!0});var jn=o(ce);Ue=r(jn,"A",{id:!0,class:!0,href:!0});var mh=o(Ue);vt=r(mh,"SPAN",{});var uh=o(vt);v(Ds.$$.fragment,uh),uh.forEach(a),mh.forEach(a),fp=f(jn),jt=r(jn,"SPAN",{});var gh=o(jt);dp=l(gh,"Filter"),gh.forEach(a),jn.forEach(a),Yl=f(e),Be=r(e,"P",{});var bn=o(Be);mp=l(bn,"You can filter rows in the dataset based on a predicate function using "),_a=r(bn,"A",{href:!0});var _h=o(_a);up=l(_h,"Dataset.filter()"),_h.forEach(a),gp=l(bn,". It returns rows that match a specified condition:"),bn.forEach(a),Vl=f(e),v(As.$$.fragment,e),Hl=f(e),fe=r(e,"P",{});var Tt=o(fe);va=r(Tt,"A",{href:!0});var vh=o(va);_p=l(vh,"Dataset.filter()"),vh.forEach(a),vp=l(Tt," can also filter by indices if you set "),bt=r(Tt,"CODE",{});var jh=o(bt);jp=l(jh,"with_indices=True"),jh.forEach(a),bp=l(Tt,":"),Tt.forEach(a),Ul=f(e),v(Is.$$.fragment,e),Bl=f(e),de=r(e,"H2",{class:!0});var xn=o(de);Ge=r(xn,"A",{id:!0,class:!0,href:!0});var bh=o(Ge);xt=r(bh,"SPAN",{});var xh=o(xt);v(Ts.$$.fragment,xh),xh.forEach(a),bh.forEach(a),xp=f(xn),$t=r(xn,"SPAN",{});var $h=o($t);$p=l($h,"Stream in a training loop"),$h.forEach(a),xn.forEach(a),Gl=f(e),Ss=r(e,"P",{});var kp=o(Ss);ja=r(kp,"A",{href:!0});var wh=o(ja);wp=l(wh,"IterableDataset"),wh.forEach(a),yp=l(kp," can be integrated into a training loop. First, shuffle the dataset:"),kp.forEach(a),Jl=f(e),v(Je.$$.fragment,e),this.h()},h(){h(d,"name","hf:doc:metadata"),h(d,"content",JSON.stringify(Fh)),h(y,"id","stream"),h(y,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(y,"href","#stream"),h(m,"class","relative group"),h(Ns,"class","block dark:hidden"),yh(Ns.src,Ep="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/streaming.gif")||h(Ns,"src",Ep),h(Ls,"class","hidden dark:block"),yh(Ls.src,Dp="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/datasets/streaming-dark.gif")||h(Ls,"src",Dp),h(X,"class","flex justify-center"),h(Xe,"href","https://huggingface.co/datasets/oscar-corpus/OSCAR-2201"),h(Xe,"rel","nofollow"),h(Ms,"href","/docs/datasets/v2.11.0/en/package_reference/loading_methods#datasets.load_dataset"),h(es,"href","https://huggingface.co/datasets/oscar-corpus/OSCAR-2201"),h(es,"rel","nofollow"),h(Rs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(Fs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(je,"id","shuffle"),h(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(je,"href","#shuffle"),h(Z,"class","relative group"),h(Ys,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(Vs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Hs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.shuffle"),h(Us,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.shuffle"),h(xe,"id","reshuffle"),h(xe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(xe,"href","#reshuffle"),h(ee,"class","relative group"),h(ye,"id","split-dataset"),h(ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(ye,"href","#split-dataset"),h(se,"class","relative group"),h(Js,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.take"),h(Ks,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.skip"),h(Qs,"id","interleave_datasets"),h(Ae,"id","interleave"),h(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ae,"href","#interleave"),h(ae,"class","relative group"),h(Xs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.interleave_datasets"),h(Zs,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(Te,"id","rename-remove-and-cast"),h(Te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Te,"href","#rename-remove-and-cast"),h(le,"class","relative group"),h(Se,"id","rename"),h(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Se,"href","#rename"),h(ne,"class","relative group"),h(sa,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.rename_column"),h(aa,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.rename_column"),h(Ce,"id","remove"),h(Ce,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ce,"href","#remove"),h(re,"class","relative group"),h(ta,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.remove_columns"),h(Ne,"id","cast"),h(Ne,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ne,"href","#cast"),h(oe,"class","relative group"),h(la,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.cast"),h(na,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.cast_column"),h(Oe,"id","map"),h(Oe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Oe,"href","#map"),h(pe,"class","relative group"),h(ra,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset.map"),h(oa,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset"),h(pa,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(ia,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(ha,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(fa,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset"),h(da,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(ma,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(ua,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(Ye,"id","batch-processing"),h(Ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ye,"href","#batch-processing"),h(ie,"class","relative group"),h(ga,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset.map"),h(Ve,"id","tokenization"),h(Ve,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ve,"href","#tokenization"),h(he,"class","relative group"),h(Ue,"id","filter"),h(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ue,"href","#filter"),h(ce,"class","relative group"),h(_a,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset.filter"),h(va,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.Dataset.filter"),h(Ge,"id","stream-in-a-training-loop"),h(Ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),h(Ge,"href","#stream-in-a-training-loop"),h(de,"class","relative group"),h(ja,"href","/docs/datasets/v2.11.0/en/package_reference/main_classes#datasets.IterableDataset")},m(e,p){s(document.head,d),i(e,w,p),i(e,m,p),s(m,y),s(y,k),j(g,k,null),s(m,E),s(m,u),s(u,D),i(e,A,p),i(e,S,p),s(S,z),i(e,P,p),i(e,q,p),s(q,I),s(I,Q),s(q,Cs),s(q,ge),s(ge,zs),s(q,$n),s(q,ka),s(ka,wn),i(e,Pt,p),i(e,X,p),s(X,Ns),s(X,yn),s(X,Ls),i(e,qt,p),i(e,R,p),s(R,kn),s(R,Xe),s(Xe,En),s(R,Dn),s(R,Ea),s(Ea,An),s(R,In),s(R,Ms),s(Ms,Tn),s(R,Sn),i(e,Ct,p),j(Ze,e,p),i(e,zt,p),i(e,Os,p),s(Os,Pn),i(e,Nt,p),i(e,U,p),s(U,Da),s(Da,qn),s(U,Cn),s(U,Aa),s(Aa,zn),s(U,Nn),s(U,Ia),s(Ia,Ln),i(e,Lt,p),i(e,_e,p),s(_e,Mn),s(_e,es),s(es,On),s(_e,Rn),i(e,Mt,p),j(ss,e,p),i(e,Ot,p),i(e,B,p),s(B,Fn),s(B,Rs),s(Rs,Yn),s(B,Vn),s(B,Fs),s(Fs,Hn),s(B,Un),i(e,Rt,p),j(ve,e,p),i(e,Ft,p),i(e,Z,p),s(Z,je),s(je,Ta),j(as,Ta,null),s(Z,Bn),s(Z,Sa),s(Sa,Gn),i(e,Yt,p),i(e,F,p),s(F,Jn),s(F,Ys),s(Ys,Wn),s(F,Kn),s(F,Vs),s(Vs,Qn),s(F,Xn),s(F,Hs),s(Hs,Zn),s(F,er),i(e,Vt,p),i(e,Y,p),s(Y,sr),s(Y,Pa),s(Pa,ar),s(Y,tr),s(Y,qa),s(qa,lr),s(Y,nr),s(Y,Us),s(Us,rr),s(Y,or),i(e,Ht,p),j(ts,e,p),i(e,Ut,p),j(be,e,p),i(e,Bt,p),i(e,ee,p),s(ee,xe),s(xe,Ca),j(ls,Ca,null),s(ee,pr),s(ee,za),s(za,ir),i(e,Gt,p),i(e,$e,p),s($e,hr),s($e,Na),s(Na,cr),s($e,fr),i(e,Jt,p),i(e,we,p),s(we,dr),s(we,La),s(La,mr),s(we,ur),i(e,Wt,p),j(ns,e,p),i(e,Kt,p),i(e,se,p),s(se,ye),s(ye,Ma),j(rs,Ma,null),s(se,gr),s(se,Oa),s(Oa,_r),i(e,Qt,p),i(e,Bs,p),s(Bs,vr),i(e,Xt,p),i(e,Gs,p),s(Gs,ke),s(ke,Js),s(Js,jr),s(ke,br),s(ke,Ra),s(Ra,xr),s(ke,$r),i(e,Zt,p),j(os,e,p),i(e,el,p),i(e,Ws,p),s(Ws,Ee),s(Ee,Ks),s(Ks,wr),s(Ee,yr),s(Ee,Fa),s(Fa,kr),s(Ee,Er),i(e,sl,p),j(ps,e,p),i(e,al,p),j(De,e,p),i(e,tl,p),i(e,Qs,p),i(e,ll,p),i(e,ae,p),s(ae,Ae),s(Ae,Ya),j(is,Ya,null),s(ae,Dr),s(ae,Va),s(Va,Ar),i(e,nl,p),i(e,te,p),s(te,Xs),s(Xs,Ir),s(te,Tr),s(te,Zs),s(Zs,Sr),s(te,Pr),i(e,rl,p),j(hs,e,p),i(e,ol,p),i(e,Ie,p),s(Ie,qr),s(Ie,Ha),s(Ha,Cr),s(Ie,zr),i(e,pl,p),j(cs,e,p),i(e,il,p),i(e,G,p),s(G,Nr),s(G,Ua),s(Ua,Lr),s(G,Mr),s(G,Ba),s(Ba,Or),s(G,Rr),i(e,hl,p),i(e,L,p),s(L,Fr),s(L,Ga),s(Ga,Yr),s(L,Vr),s(L,Ja),s(Ja,Hr),s(L,Ur),s(L,Wa),s(Wa,Br),s(L,Gr),s(L,Ka),s(Ka,Jr),s(L,Wr),i(e,cl,p),i(e,le,p),s(le,Te),s(Te,Qa),j(fs,Qa,null),s(le,Kr),s(le,Xa),s(Xa,Qr),i(e,fl,p),i(e,ea,p),s(ea,Xr),i(e,dl,p),i(e,ne,p),s(ne,Se),s(Se,Za),j(ds,Za,null),s(ne,Zr),s(ne,et),s(et,eo),i(e,ml,p),i(e,Pe,p),s(Pe,so),s(Pe,sa),s(sa,ao),s(Pe,to),i(e,ul,p),i(e,qe,p),s(qe,lo),s(qe,aa),s(aa,no),s(qe,ro),i(e,gl,p),j(ms,e,p),i(e,_l,p),i(e,re,p),s(re,Ce),s(Ce,st),j(us,st,null),s(re,oo),s(re,at),s(at,po),i(e,vl,p),i(e,ze,p),s(ze,io),s(ze,ta),s(ta,ho),s(ze,co),i(e,jl,p),j(gs,e,p),i(e,bl,p),i(e,oe,p),s(oe,Ne),s(Ne,tt),j(_s,tt,null),s(oe,fo),s(oe,lt),s(lt,mo),i(e,xl,p),i(e,O,p),s(O,la),s(la,uo),s(O,go),s(O,nt),s(nt,_o),s(O,vo),s(O,rt),s(rt,jo),s(O,bo),s(O,ot),s(ot,xo),s(O,$o),i(e,$l,p),j(vs,e,p),i(e,wl,p),j(Le,e,p),i(e,yl,p),i(e,Me,p),s(Me,wo),s(Me,na),s(na,yo),s(Me,ko),i(e,kl,p),j(js,e,p),i(e,El,p),i(e,pe,p),s(pe,Oe),s(Oe,pt),j(bs,pt,null),s(pe,Eo),s(pe,it),s(it,Do),i(e,Dl,p),i(e,N,p),s(N,Ao),s(N,ra),s(ra,Io),s(N,To),s(N,oa),s(oa,So),s(N,Po),s(N,pa),s(pa,qo),s(N,Co),s(N,ia),s(ia,zo),s(N,No),s(N,ha),s(ha,Lo),s(N,Mo),i(e,Al,p),i(e,ca,p),s(ca,Oo),i(e,Il,p),i(e,J,p),s(J,Ro),s(J,fa),s(fa,Fo),s(J,Yo),s(J,ht),s(ht,Vo),s(J,Ho),i(e,Tl,p),j(xs,e,p),i(e,Sl,p),i(e,Re,p),s(Re,Uo),s(Re,da),s(da,Bo),s(Re,Go),i(e,Pl,p),j($s,e,p),i(e,ql,p),i(e,Fe,p),s(Fe,Jo),s(Fe,ma),s(ma,Wo),s(Fe,Ko),i(e,Cl,p),i(e,W,p),s(W,Qo),s(W,ct),s(ct,Xo),s(W,Zo),s(W,ua),s(ua,ep),s(W,sp),i(e,zl,p),j(ws,e,p),i(e,Nl,p),i(e,ie,p),s(ie,Ye),s(Ye,ft),j(ys,ft,null),s(ie,ap),s(ie,dt),s(dt,tp),i(e,Ll,p),i(e,H,p),s(H,ga),s(ga,lp),s(H,np),s(H,mt),s(mt,rp),s(H,op),s(H,ut),s(ut,pp),s(H,ip),i(e,Ml,p),i(e,he,p),s(he,Ve),s(Ve,gt),j(ks,gt,null),s(he,hp),s(he,_t),s(_t,cp),i(e,Ol,p),j(Es,e,p),i(e,Rl,p),j(He,e,p),i(e,Fl,p),i(e,ce,p),s(ce,Ue),s(Ue,vt),j(Ds,vt,null),s(ce,fp),s(ce,jt),s(jt,dp),i(e,Yl,p),i(e,Be,p),s(Be,mp),s(Be,_a),s(_a,up),s(Be,gp),i(e,Vl,p),j(As,e,p),i(e,Hl,p),i(e,fe,p),s(fe,va),s(va,_p),s(fe,vp),s(fe,bt),s(bt,jp),s(fe,bp),i(e,Ul,p),j(Is,e,p),i(e,Bl,p),i(e,de,p),s(de,Ge),s(Ge,xt),j(Ts,xt,null),s(de,xp),s(de,$t),s($t,$p),i(e,Gl,p),i(e,Ss,p),s(Ss,ja),s(ja,wp),s(Ss,yp),i(e,Jl,p),j(Je,e,p),Wl=!0},p(e,[p]){const Ps={};p&2&&(Ps.$$scope={dirty:p,ctx:e}),ve.$set(Ps);const wt={};p&2&&(wt.$$scope={dirty:p,ctx:e}),be.$set(wt);const yt={};p&2&&(yt.$$scope={dirty:p,ctx:e}),De.$set(yt);const kt={};p&2&&(kt.$$scope={dirty:p,ctx:e}),Le.$set(kt);const Et={};p&2&&(Et.$$scope={dirty:p,ctx:e}),He.$set(Et);const me={};p&2&&(me.$$scope={dirty:p,ctx:e}),Je.$set(me)},i(e){Wl||(b(g.$$.fragment,e),b(Ze.$$.fragment,e),b(ss.$$.fragment,e),b(ve.$$.fragment,e),b(as.$$.fragment,e),b(ts.$$.fragment,e),b(be.$$.fragment,e),b(ls.$$.fragment,e),b(ns.$$.fragment,e),b(rs.$$.fragment,e),b(os.$$.fragment,e),b(ps.$$.fragment,e),b(De.$$.fragment,e),b(is.$$.fragment,e),b(hs.$$.fragment,e),b(cs.$$.fragment,e),b(fs.$$.fragment,e),b(ds.$$.fragment,e),b(ms.$$.fragment,e),b(us.$$.fragment,e),b(gs.$$.fragment,e),b(_s.$$.fragment,e),b(vs.$$.fragment,e),b(Le.$$.fragment,e),b(js.$$.fragment,e),b(bs.$$.fragment,e),b(xs.$$.fragment,e),b($s.$$.fragment,e),b(ws.$$.fragment,e),b(ys.$$.fragment,e),b(ks.$$.fragment,e),b(Es.$$.fragment,e),b(He.$$.fragment,e),b(Ds.$$.fragment,e),b(As.$$.fragment,e),b(Is.$$.fragment,e),b(Ts.$$.fragment,e),b(Je.$$.fragment,e),Wl=!0)},o(e){x(g.$$.fragment,e),x(Ze.$$.fragment,e),x(ss.$$.fragment,e),x(ve.$$.fragment,e),x(as.$$.fragment,e),x(ts.$$.fragment,e),x(be.$$.fragment,e),x(ls.$$.fragment,e),x(ns.$$.fragment,e),x(rs.$$.fragment,e),x(os.$$.fragment,e),x(ps.$$.fragment,e),x(De.$$.fragment,e),x(is.$$.fragment,e),x(hs.$$.fragment,e),x(cs.$$.fragment,e),x(fs.$$.fragment,e),x(ds.$$.fragment,e),x(ms.$$.fragment,e),x(us.$$.fragment,e),x(gs.$$.fragment,e),x(_s.$$.fragment,e),x(vs.$$.fragment,e),x(Le.$$.fragment,e),x(js.$$.fragment,e),x(bs.$$.fragment,e),x(xs.$$.fragment,e),x($s.$$.fragment,e),x(ws.$$.fragment,e),x(ys.$$.fragment,e),x(ks.$$.fragment,e),x(Es.$$.fragment,e),x(He.$$.fragment,e),x(Ds.$$.fragment,e),x(As.$$.fragment,e),x(Is.$$.fragment,e),x(Ts.$$.fragment,e),x(Je.$$.fragment,e),Wl=!1},d(e){a(d),e&&a(w),e&&a(m),$(g),e&&a(A),e&&a(S),e&&a(P),e&&a(q),e&&a(Pt),e&&a(X),e&&a(qt),e&&a(R),e&&a(Ct),$(Ze,e),e&&a(zt),e&&a(Os),e&&a(Nt),e&&a(U),e&&a(Lt),e&&a(_e),e&&a(Mt),$(ss,e),e&&a(Ot),e&&a(B),e&&a(Rt),$(ve,e),e&&a(Ft),e&&a(Z),$(as),e&&a(Yt),e&&a(F),e&&a(Vt),e&&a(Y),e&&a(Ht),$(ts,e),e&&a(Ut),$(be,e),e&&a(Bt),e&&a(ee),$(ls),e&&a(Gt),e&&a($e),e&&a(Jt),e&&a(we),e&&a(Wt),$(ns,e),e&&a(Kt),e&&a(se),$(rs),e&&a(Qt),e&&a(Bs),e&&a(Xt),e&&a(Gs),e&&a(Zt),$(os,e),e&&a(el),e&&a(Ws),e&&a(sl),$(ps,e),e&&a(al),$(De,e),e&&a(tl),e&&a(Qs),e&&a(ll),e&&a(ae),$(is),e&&a(nl),e&&a(te),e&&a(rl),$(hs,e),e&&a(ol),e&&a(Ie),e&&a(pl),$(cs,e),e&&a(il),e&&a(G),e&&a(hl),e&&a(L),e&&a(cl),e&&a(le),$(fs),e&&a(fl),e&&a(ea),e&&a(dl),e&&a(ne),$(ds),e&&a(ml),e&&a(Pe),e&&a(ul),e&&a(qe),e&&a(gl),$(ms,e),e&&a(_l),e&&a(re),$(us),e&&a(vl),e&&a(ze),e&&a(jl),$(gs,e),e&&a(bl),e&&a(oe),$(_s),e&&a(xl),e&&a(O),e&&a($l),$(vs,e),e&&a(wl),$(Le,e),e&&a(yl),e&&a(Me),e&&a(kl),$(js,e),e&&a(El),e&&a(pe),$(bs),e&&a(Dl),e&&a(N),e&&a(Al),e&&a(ca),e&&a(Il),e&&a(J),e&&a(Tl),$(xs,e),e&&a(Sl),e&&a(Re),e&&a(Pl),$($s,e),e&&a(ql),e&&a(Fe),e&&a(Cl),e&&a(W),e&&a(zl),$(ws,e),e&&a(Nl),e&&a(ie),$(ys),e&&a(Ll),e&&a(H),e&&a(Ml),e&&a(he),$(ks),e&&a(Ol),$(Es,e),e&&a(Rl),$(He,e),e&&a(Fl),e&&a(ce),$(Ds),e&&a(Yl),e&&a(Be),e&&a(Vl),$(As,e),e&&a(Hl),e&&a(fe),e&&a(Ul),$(Is,e),e&&a(Bl),e&&a(de),$(Ts),e&&a(Gl),e&&a(Ss),e&&a(Jl),$(Je,e)}}}const Fh={local:"stream",sections:[{local:"shuffle",title:"Shuffle"},{local:"reshuffle",title:"Reshuffle"},{local:"split-dataset",title:"Split dataset"},{local:"interleave",title:"Interleave"},{local:"rename-remove-and-cast",sections:[{local:"rename",title:"Rename"},{local:"remove",title:"Remove"},{local:"cast",title:"Cast"}],title:"Rename, remove, and cast"},{local:"map",sections:[{local:"batch-processing",sections:[{local:"tokenization",title:"Tokenization"}],title:"Batch processing"},{local:"filter",title:"Filter"}],title:"Map"},{local:"stream-in-a-training-loop",title:"Stream in a training loop"}],title:"Stream"};function Yh(C){return Ih(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wh extends kh{constructor(d){super();Eh(this,d,Yh,Rh,Dh,{})}}export{Wh as default,Fh as metadata};
