You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
String columns are copied through a fixed-width numpy <U{maxlen} array #79
Under the "julia" format, string columns go through a fixed-width numpy unicode array before reaching Julia. datasets' numpy extractor calls np.asarray(list_of_str), which allocates a <U{maxlen} (UTF-32) array, and py2jl's non-numeric branch then converts it back with x.tolist() (src/transforms.jl:~70).
The temporary takes batch_size × maxlen × 4 bytes. For long-document corpora such as HuggingFaceFW/fineweb-edu (documents up to ~100k characters), a batch of 1000 documents allocates hundreds of MB just to produce a Vector{String}, and every string is converted twice. Extracting string columns directly from Arrow, or with the Python formatter (to_pylist), would avoid this.
Environment: HuggingFaceDatasets v0.4.2 (the relevant code is unchanged on master), Python datasets 4.8.5, Julia 1.13.2.
This also applies to streaming datasets, where the impact is much larger. load_dataset(...; streaming=true) sets the same numpy-backed format on the IterableDataset, so .iter(batch_size=...) yields each text column as one fixed-width <U{maxlen} array:
One 485k-character document sets the width for the whole batch. Tokenizing FineWeb-Edu this way grew the process to more than 60 GB of RSS after 1B tokens, and ran about 6× slower than with plain lists (ds.py.with_format(nothing)), which give a 10k-document batch in ~1.8 s.
Activity
CarloLucibello commentedon Oct 19, 2026
This also applies to streaming datasets, where the impact is much larger.
load_dataset(...; streaming=true)sets the same numpy-backed format on theIterableDataset, so.iter(batch_size=...)yields each text column as one fixed-width<U{maxlen}array:One 485k-character document sets the width for the whole batch. Tokenizing FineWeb-Edu this way grew the process to more than 60 GB of RSS after 1B tokens, and ran about 6× slower than with plain lists (
ds.py.with_format(nothing)), which give a 10k-document batch in ~1.8 s.Read string columns without a fixed-width numpy array
Read string columns without a fixed-width numpy array (#87)