Skip to content

"julia" format silently changes column dtypes (integers to Int64, Float64 to Float32) #78

Closed

Description

@CarloLucibello

The "julia" format sets the Python format to "numpy" (src/dataset.jl:433), and datasets' NumpyFormatter._tensorize casts every integer array to np.int64 and every floating-point array to np.float32, regardless of the column's feature type. So under the default format:

using HuggingFaceDatasets, HuggingFaceDatasets.PythonCall
np = pyimport("numpy")
feats = datasets.Features(pydict(Dict(
    "u16" => datasets.List(datasets.Value("uint16")),
    "f64" => datasets.Value("float64"),
    "s"   => datasets.Value("string"))))
pyds = datasets.Dataset.from_dict(pydict(Dict(
    "u16" => pylist([np.array([1, 2], dtype=np.uint16), np.array([3, 4], dtype=np.uint16)]),
    "f64" => pylist([1.0000000001, 2.0]),
    "s"   => pylist(["a", "b"^50]))); features=feats)
ds = with_format(Dataset(pyds), "julia")
julia> b = ds[1:2];

julia> typeof(b["u16"]), typeof(b["f64"])
(Matrix{Int64}, Vector{Float32})

julia> b["f64"][1] == 1.0000000001
false
  • A uint16 column (e.g. pre-tokenized LM data) comes back 4× larger as Int64.
  • A float64 column silently loses precision.

Since the "julia" format is now the default, users get this without asking for it. It would be better to keep the Arrow dtype, for example with a "julia" formatter that skips the default-dtype cast (or passes dtype=None), or at least to document it.

Environment: HuggingFaceDatasets v0.4.2 (the relevant code is unchanged on master), Python datasets 4.8.5, Julia 1.13.2.

Activity

  1. CarloLucibello commented on Oct 19, 2026

    @CarloLucibello
    CollaboratorAuthor

    yes we should decouple the julia format from the numpy one

  2. added a commit that references this issue on Oct 19, 2026
    0d66e59
  3. added a commit that references this issue on Oct 19, 2026
    b4a9a43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions