Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
image

SmolVLM-256M β€” Core ML golden test vectors

Reference tensors and token id sequences that let any reimplementation of SmolVLM-256M's preprocessing and tokenization prove itself bit-exact against the HuggingFace reference, without installing Python, transformers, or Pillow at verification time.

This is the verify half of the NagaYu/smolvlm-coreml project. The runnable Core ML packages live separately in NagaYu/SmolVLM-256M-Instruct-CoreML.

What this is β€” and what it is not

It is six small files, ~43 MB total: the exact bytes that HuggingFace transformers produces for one image and one question, captured at every stage a from-scratch port can get wrong β€” raw JPEG decode, resize, normalization, chat-template tokenization.

It is not training data, evaluation data, or a benchmark. There is one image and one prompt. Nothing here is meant to be learned from, fine-tuned on, or scored against. It is a set of assertions.

The intended use is blunt: you reimplement SmolVLM's preprocessing in another language β€” Swift, Rust, C++, whatever β€” and you want to know whether your JPEG decoder, your LANCZOS resampler, and your BPE tokenizer agree with the Python reference to the last bit, not "close enough". These vectors answer that question, and they answer it offline.

This is a plain-file dataset. Load it with hf_hub_download / snapshot_download or hf download NagaYu/smolvlm-coreml-golden --repo-type dataset β€” not datasets.load_dataset; there is no dataset script and no Arrow conversion.

Files

Layout mirrors the companion repository, so downloading with --local-dir . into a clone puts every file exactly where the Swift CLI's --root . already looks for it.

Path in this repo Format Contents
exports/golden.json JSON {"question", "prompt_ids"} β€” 81 prompt token ids, non-split path
exports/golden_split.json JSON same shape β€” 876 prompt token ids, 13-tile split path
exports/golden_pixel_values.bin raw float32, C-order [3, 512, 512] preprocessed pixels, non-split (3,145,728 bytes)
exports/golden_pixel_values_split.bin raw float32, C-order [13, 3, 512, 512] preprocessed pixels, hi-res path (40,894,464 bytes)
exports/pil_decode.npy NumPy .npy, uint8 [480, 640, 3] β€” the raw Pillow decode of test_image.jpg
test_image.jpg JPEG 640Γ—480, baseline, 4:4:4, the single source image (126 KB)

Notes on the two that need them:

  • golden_pixel_values_split.bin is the 13-tile hi-res path: a 3Γ—4 grid of crops plus one global downscaled view, in that order β€” 12 + 1 = 13 tiles of [3, 512, 512]. The 876-token prompt in golden_split.json is what the chat template expands to once those 13 tiles' image tokens are inlined.
  • pil_decode.npy is the oracle that makes a from-scratch JPEG decoder testable in isolation. Comparing your final preprocessed tensor against golden_pixel_values.bin tells you something is wrong; it does not tell you whether the fault is in your decoder or your resampler. pil_decode.npy is Pillow's (libjpeg's) decode of test_image.jpg before any resizing, so you can prove decoder parity on its own, then feed those same uint8 pixels into your resampler and prove that on its own. That separation is the reason this file exists.

Both .bin files are headerless β€” dtype and shape are not stored in them, they are stated above and asserted below.

Loading

import json
import numpy as np
from huggingface_hub import snapshot_download

root = snapshot_download("NagaYu/smolvlm-coreml-golden", repo_type="dataset")

# --- token id goldens ---------------------------------------------------
g = json.load(open(f"{root}/exports/golden.json"))
g["question"]                       # "What is in this image?"
ids = g["prompt_ids"]               # list[int], len == 81

gs = json.load(open(f"{root}/exports/golden_split.json"))
ids_split = gs["prompt_ids"]        # list[int], len == 876

# --- preprocessed pixel goldens (headerless raw float32, C-order) -------
px = np.fromfile(f"{root}/exports/golden_pixel_values.bin",
                 dtype=np.float32).reshape(3, 512, 512)          # (3, 512, 512) float32

px_split = np.fromfile(f"{root}/exports/golden_pixel_values_split.bin",
                       dtype=np.float32).reshape(13, 3, 512, 512)  # (13, 3, 512, 512) float32

# --- raw Pillow decode oracle (standard .npy, has its own header) -------
pil = np.load(f"{root}/exports/pil_decode.npy")                  # (480, 640, 3) uint8

assert len(ids) == 81 and len(ids_split) == 876
assert px.dtype == np.float32 and px.shape == (3, 512, 512)
assert px_split.shape == (13, 3, 512, 512)
assert pil.dtype == np.uint8 and pil.shape == (480, 640, 3)

From a non-Python runtime, the .bin files are just np.prod(shape) little-endian float32s in C order β€” read them straight into a buffer. pil_decode.npy carries a NumPy v1 header: bytes 8–9 are the little-endian header length, pixel data starts at 10 + header_len, then 480 * 640 * 3 uint8 in HWC order.

What was actually proven against these vectors

Measured on macOS 26.5 (Darwin 25.5.0), Apple silicon arm64, Python 3.13, Swift 6.3, coremltools 9.0, by the zero-dependency Swift CLI in the companion repo:

Check Result
Tokenizer, non-split Exact β€” 81/81 ids match golden.json
Tokenizer, split Exact β€” 876/876 ids match golden_split.json
JPEG decode vs libjpeg maxdiff 0/255 β€” custom Swift baseline decoder vs pil_decode.npy
Resize vs Pillow LANCZOS maxdiff 0.000000 β€” including Pillow's fixed-point arithmetic (PRECISION_BITS = 22)
Normalization Exact on all 256 input values

Re-run on macOS 27.2 (Darwin 27.2.0), Apple M2, Swift 6.4 against these same files, with the same results for the first four rows: 81/81, 876/876, maxdiff 0/255 and maxdiff 0.000000. The full non-split tensor compared at maxdiff 0.0002 / meandiff 0.0001, which is within fp16 rounding (see the caveat below). The normalization row was not re-checked separately; --check does not print it on its own.

Re-prove it yourself with the CLI's --check mode, which reads exactly these files:

./SmolVLMSwift/.build/release/smolvlm --check --root .
./SmolVLMSwift/.build/release/smolvlm --check --split --root .

One honest caveat on the pixel comparison: --check holds its tiles in fp16 while the goldens are fp32, so the full-tensor golden_pixel_values*.bin comparison prints a maxdiff/meandiff magnitude, not a bit verdict. The bit-exact claims above come from the isolated stages β€” decoder vs pil_decode.npy in uint8, and the resampler run on those same uint8 pixels β€” which is precisely why pil_decode.npy is shipped.

Regeneration

These vectors are derived, not sacred. They are one deterministic function of the upstream model's processor config, and you should regenerate them rather than trust a stale copy if you change anything upstream:

git clone https://github.com/NagaYu/smolvlm-coreml && cd smolvlm-coreml
pip install torch transformers pillow
python export_artifacts.py --image test_image.jpg --question "What is in this image?"

That writes all five files above into exports/. It also writes embeddings.bin, tok/, and specials.json β€” runtime assets that belong to the model repo, not this one; they are excluded here on purpose so the split stays "everything needed to RUN" vs "everything needed to VERIFY".

Regenerate whenever you bump transformers, change the question string, or swap the image. The 81/876 token counts are specific to the default question "What is in this image?".

Why there are no expected-caption strings

Deliberately absent, and this is the single most important thing to know before you build a regression test on top of this dataset.

Greedy decode output drifted across OS sessions days apart on the measured environment β€” same machine, same packages, inputs verified bit-identical at every stage β€” while remaining fully deterministic within a session and across processes. The likely cause is last-ulp changes in GPU kernels between system updates. (This is finding 7 of the field report; it reproduces on the stated environment and is not asserted to be a bug in absolute terms.)

The consequence: a saved caption string is not a valid golden across OS updates. So this dataset stops where determinism stops. Preprocessing and tokenization are pure integer and fixed-point work that runs identically everywhere β€” those get bit-exact goldens. Anything downstream of a GPU matmul does not, and shipping a caption here would only manufacture false failures on someone else's macOS build.

If you need end-to-end assurance, derive the caption on your current OS and treat it as a within-session baseline, not a committed artifact.

Licensing & attribution

  • Golden tensors and token ids: derived from HuggingFaceTB/SmolVLM-256M-Instruct (Apache 2.0) by running its own processor and tokenizer. Released under Apache 2.0 to match. All credit for the model goes to the SmolVLM authors at HuggingFaceTB.
  • test_image.jpg: "Tabby cat with blue eyes" from Wikimedia Commons, CC0 (public domain dedication), re-encoded to 640Γ—480 baseline 4:4:4 JPEG so that a minimal baseline-only decoder can be verified against libjpeg on it.
  • Generation script (export_artifacts.py) and the Swift CLI: MIT, in the companion repository.

Related

Downloads last month
56