Dataset Viewer
Auto-converted to Parquet Duplicate
id
int64
0
60k
image
imagewidth (px)
28
28
label
int32
0
9
label_name
stringclasses
10 values
image_emb
list
0
5
5
[ 0.014190673828125, -0.05462646484375, 0.0016145706176757812, 0.0137939453125, -0.004344940185546875, -0.023345947265625, 0.035614013671875, 0.01502227783203125, -0.0142059326171875, -0.02117919921875, -0.023193359375, -0.01251220703125, 0.0060882568359375, 0.05279541015625, -0.0002149343...
1
0
0
[ 0.049102783203125, -0.143310546875, -0.00635528564453125, -0.040740966796875, -0.020416259765625, -0.00949859619140625, 0.026153564453125, 0.00743865966796875, -0.031280517578125, -0.0029392242431640625, -0.001739501953125, -0.0199127197265625, 0.0038433074951171875, 0.03857421875, -0.00...
2
4
4
[ 0.004230499267578125, 0.0038928985595703125, 0.004276275634765625, 0.0213623046875, -0.01378631591796875, -0.004726409912109375, 0.046173095703125, 0.0016183853149414062, 0.002780914306640625, 0.0110931396484375, -0.004119873046875, -0.0071563720703125, 0.0027408599853515625, 0.04473876953...
3
1
1
[ 0.0236663818359375, -0.04583740234375, -0.004383087158203125, -0.017333984375, -0.00034880638122558594, 0.0106658935546875, 0.039520263671875, 0.04022216796875, -0.020538330078125, -0.025146484375, -0.0110015869140625, 0.005954742431640625, 0.00839996337890625, 0.0290069580078125, 0.0190...
4
9
9
[ 0.00861358642578125, 0.00868988037109375, 0.0204925537109375, -0.021270751953125, -0.0014171600341796875, -0.0156707763671875, 0.0230255126953125, 0.042694091796875, -0.047515869140625, 0.00853729248046875, 0.007587432861328125, -0.013397216796875, -0.01099395751953125, 0.0273590087890625,...
5
2
2
[ 0.027740478515625, -0.056793212890625, 0.0186767578125, -0.041595458984375, -0.006847381591796875, 0.01119232177734375, 0.015350341796875, -0.007335662841796875, -0.047210693359375, 0.0091705322265625, -0.003917694091796875, -0.04119873046875, 0.0092010498046875, 0.0145111083984375, 0.00...
6
1
1
[ 0.01251983642578125, -0.08197021484375, -0.0107269287109375, -0.00728607177734375, 0.01062774658203125, -0.01024627685546875, 0.009979248046875, 0.046142578125, -0.0321044921875, -0.024322509765625, -0.0203704833984375, 0.0189361572265625, 0.0230712890625, 0.01155853271484375, -0.0052108...
7
3
3
[ 0.0253448486328125, -0.09222412109375, 0.0257415771484375, -0.0047454833984375, -0.034271240234375, 0.007389068603515625, 0.0172119140625, 0.0364990234375, -0.01297760009765625, 0.03204345703125, -0.0070648193359375, -0.0044403076171875, 0.0130615234375, 0.053192138671875, -0.00161361694...
8
1
1
[ 0.00930023193359375, -0.098388671875, -0.0185699462890625, -0.03125, -0.013885498046875, -0.0228271484375, 0.0251617431640625, 0.06488037109375, -0.0238189697265625, -0.00891876220703125, -0.0014619827270507812, 0.0252227783203125, 0.01074981689453125, -0.0180511474609375, -0.00926208496...
9
4
4
[ 0.01174163818359375, -0.10394287109375, 0.00519561767578125, -0.01447296142578125, -0.00920867919921875, -0.0032100677490234375, 0.0096893310546875, 0.03985595703125, -0.03704833984375, -0.034423828125, -0.010223388671875, -0.0130157470703125, 0.00853729248046875, 0.036346435546875, 0.03...
10
3
3
[ 0.032379150390625, -0.0880126953125, 0.0005030632019042969, -0.004566192626953125, -0.0222015380859375, 0.028106689453125, 0.02789306640625, 0.0298919677734375, -0.01201629638671875, -0.01416778564453125, -0.017974853515625, -0.0033016204833984375, 0.03826904296875, 0.0328369140625, -0.0...
11
5
5
[ 0.020660400390625, -0.0347900390625, -0.0311279296875, -0.031524658203125, -0.004642486572265625, -0.0009622573852539062, 0.038726806640625, 0.0293426513671875, -0.040374755859375, -0.049530029296875, -0.0184173583984375, 0.0003876686096191406, 0.0081024169921875, 0.0235595703125, 0.0249...
12
3
3
[ 0.031524658203125, -0.053924560546875, 0.0121307373046875, -0.01433563232421875, -0.0275726318359375, 0.030242919921875, 0.01116180419921875, 0.03265380859375, -0.005550384521484375, 0.0206298828125, -0.01264190673828125, 0.0110015869140625, -0.0007152557373046875, 0.07867431640625, 0.00...
13
6
6
[ 0.0143280029296875, -0.06768798828125, 0.0007395744323730469, -0.02557373046875, -0.01153564453125, -0.0002734661102294922, 0.062286376953125, 0.0218048095703125, -0.01407623291015625, -0.01119232177734375, -0.016632080078125, -0.0107269287109375, 0.005611419677734375, 0.01387786865234375,...
14
1
1
[ -0.00689697265625, -0.07452392578125, -0.00969696044921875, -0.001220703125, -0.0247344970703125, -0.0009655952453613281, 0.01641845703125, 0.033843994140625, -0.0259246826171875, 0.006214141845703125, -0.0212554931640625, -0.002376556396484375, 0.0220184326171875, 0.0076751708984375, 0....
15
7
7
[ 0.0362548828125, -0.06884765625, 0.01242828369140625, -0.043060302734375, 0.00669097900390625, 0.019256591796875, 0.038330078125, 0.0250244140625, -0.029296875, -0.0124969482421875, 0.003696441650390625, 0.004116058349609375, 0.0031490325927734375, 0.045745849609375, 0.032989501953125, ...
16
2
2
[ -0.003269195556640625, -0.0038280487060546875, 0.0141448974609375, -0.01557159423828125, -0.005840301513671875, 0.0002644062042236328, 0.040374755859375, 0.0217437744140625, -0.018707275390625, 0.0080413818359375, -0.0128021240234375, -0.01123809814453125, 0.036346435546875, 0.000152945518...
17
8
8
[ 0.044097900390625, -0.11138916015625, 0.0028858184814453125, -0.0222015380859375, 0.0010433197021484375, -0.0030670166015625, 0.01751708984375, 0.03759765625, -0.0304412841796875, -0.01218414306640625, -0.0168914794921875, -0.0228271484375, 0.00959014892578125, 0.03350830078125, 0.052124...
18
6
6
[ -0.0033092498779296875, 0.0156707763671875, -0.0027713775634765625, -0.054443359375, 0.0023059844970703125, 0.03948974609375, 0.01271820068359375, 0.032867431640625, -0.0340576171875, 0.0150604248046875, -0.0272674560546875, -0.00836944580078125, -0.0186004638671875, -0.0090789794921875, ...
19
9
9
[ 0.033599853515625, -0.05169677734375, 0.010955810546875, -0.044219970703125, 0.005947113037109375, 0.0013113021850585938, 0.025390625, 0.043243408203125, -0.0401611328125, 0.00144195556640625, 0.011138916015625, 0.01453399658203125, -0.0104217529296875, 0.01763916015625, 0.01258850097656...
End of preview. Expand in Data Studio

YAML Metadata Warning:The task_categories "lance" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

MNIST (Lance Format)

A Lance-formatted version of the classic MNIST handwritten-digit dataset covering 70,000 28×28 grayscale digits across ten balanced classes. Each row carries inline PNG bytes, the digit label, the human-readable class name, and a cosine-normalized CLIP image embedding, all backed by a bundled IVF_PQ vector index plus scalar indices on the label columns and available directly from the Hub at hf://datasets/lance-format/mnist-lance/data.

Key features

  • Inline PNG bytes in the image column — no sidecar files, no image folders.
  • Pre-computed CLIP image embeddings (OpenCLIP ViT-B-32 / laion2b_s34b_b79k, 512-dim, cosine-normalized) with a bundled IVF_PQ index.
  • Scalar indices on both label columnsBTREE on label and BITMAP on label_name — so digit filters and digit-conditioned search are constant-time lookups.
  • One columnar dataset — scan labels cheaply, then fetch image bytes only for the rows you want.

Splits

Split Rows
train.lance 60,000
test.lance 10,000

Schema

Column Type Notes
id int64 Row index within the split (natural join key for merges)
image large_binary Inline PNG bytes (28×28 grayscale)
label int32 Digit class id (0–9)
label_name string Human-readable class ("0".."9")
image_emb fixed_size_list<float32, 512> CLIP image embedding (cosine-normalized)

Pre-built indices

  • IVF_PQ on image_emb — vector similarity search (cosine)
  • BTREE on label — fast equality and range filters on the digit id
  • BITMAP on label_name — fast filters across the ten class names

Why Lance?

  1. Blazing Fast Random Access: Optimized for fetching scattered rows, making it ideal for random sampling, real-time ML serving, and interactive applications without performance degradation.
  2. Native Multimodal Support: Store text, embeddings, and other data types together in a single file. Large binary objects are loaded lazily, and vectors are optimized for fast similarity search.
  3. Native Index Support: Lance comes with fast, on-disk, scalable vector and FTS indexes that sit right alongside the dataset on the Hub, so you can share not only your data but also your embeddings and indexes without your users needing to recompute them.
  4. Efficient Data Evolution: Add new columns and backfill data without rewriting the entire dataset. This is perfect for evolving ML features, adding new embeddings, or introducing moderation tags over time.
  5. Versatile Querying: Supports combining vector similarity search, full-text search, and SQL-style filtering in a single query, accelerated by on-disk indexes.
  6. Data Versioning: Every mutation commits a new version; previous versions remain intact on disk. Tags pin a snapshot by name, so retrieval systems and training runs can reproduce against an exact slice of history.

Load with datasets.load_dataset

You can load Lance datasets via the standard HuggingFace datasets interface, suitable if your pipeline already speaks Dataset / IterableDataset or you want a quick streaming sample without installing anything Lance-specific.

import datasets

hf_ds = datasets.load_dataset("lance-format/mnist-lance", split="train", streaming=True)
for row in hf_ds.take(3):
    print(row["label"], row["label_name"])

Load with LanceDB

LanceDB is the embedded retrieval library built on top of the Lance format (docs), and is the interface most users interact with. It wraps the dataset as a queryable table with search and filter builders, and is the entry point used by the Search, Curate, Evolve, Train, Versioning, and Materialize-a-subset sections below.

import lancedb

db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
tbl = db.open_table("train")
print(len(tbl))

Load with Lance

pylance is the Python binding for the Lance format and works directly with the format's lower-level APIs. Reach for it when you want to inspect or operate on dataset internals — schema, scanner, fragments, and the list of pre-built indices.

import lance

ds = lance.dataset("hf://datasets/lance-format/mnist-lance/data/train.lance")
print(ds.count_rows(), ds.schema.names)
print(ds.list_indices())

Tip — for production use, download locally first. Streaming from the Hub works for exploration, but heavy random access and ANN search are far faster against a local copy:

hf download lance-format/mnist-lance --repo-type dataset --local-dir ./mnist-lance

Then point Lance or LanceDB at ./mnist-lance/data.

Search

The bundled IVF_PQ index on image_emb turns nearest-neighbor lookup on the 512-d CLIP space into a single call. In production you would encode a query digit through OpenCLIP ViT-B-32 at runtime and pass the resulting vector to tbl.search(...). The example below uses the embedding already stored in row 42 as a runnable stand-in so the snippet works without any model loaded.

import lancedb

db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
tbl = db.open_table("train")

seed = (
    tbl.search()
    .select(["image_emb", "label"])
    .limit(1)
    .offset(42)
    .to_list()[0]
)

hits = (
    tbl.search(seed["image_emb"])
    .metric("cosine")
    .select(["id", "label", "label_name"])
    .limit(10)
    .to_list()
)
print("query digit:", seed["label"])
for r in hits:
    print(f"  id={r['id']:>5}  label={r['label']}")

Because the embeddings are cosine-normalized and MNIST digits cluster tightly in CLIP space, near-neighbors of a seed image are dominated by the seed's own digit class — a useful sanity check before swapping in a real query encoder. Tune metric, nprobes, and refine_factor to trade recall against latency.

Curate

A typical curation pass for a digit-classification workflow narrows the table to a single digit (or a small set of confusable digits like 4/9 or 3/8) before sampling. Because both label columns are indexed, the filter resolves without scanning the embedding or image bytes; the bounded .limit(500) keeps the output small enough to inspect or hand off as a manifest of row ids.

import lancedb

db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
tbl = db.open_table("train")

candidates = (
    tbl.search()
    .where("label IN (4, 9)", prefilter=True)
    .select(["id", "label", "label_name"])
    .limit(500)
    .to_list()
)
print(f"{len(candidates)} 4/9 candidates")

The result is a plain list of dictionaries, ready to inspect, persist as a manifest of ids, or feed into the Evolve and Train workflows below. The image and image_emb columns are never read, so the network traffic for a 500-row candidate scan is dominated by the tiny label payload.

Evolve

Lance stores each column independently, so a new column can be appended without rewriting the existing data. The lightest form is a SQL expression: derive the new column from columns that already exist, and Lance computes it once and persists it. The example below adds an is_target_class flag for binary one-vs-rest experiments and an is_curvy_digit flag that groups digits with curved strokes, either of which can then be used directly in where clauses without recomputing the predicate on every query.

Note: Mutations require a local copy of the dataset, since the Hub mount is read-only. See the Materialize-a-subset section at the end of this card for a streaming pattern that downloads only the rows and columns you need, or use hf download to pull the full corpus first.

import lancedb

db = lancedb.connect("./mnist-lance/data")  # local copy required for writes
tbl = db.open_table("train")

tbl.add_columns({
    "is_target_class": "label = 7",
    "is_curvy_digit": "label IN (0, 3, 6, 8, 9)",
})

If the values you want to attach already live in another table (offline labels from a stronger model, classifier predictions, per-row confidence scores), merge them in by joining on the id column:

import pyarrow as pa

predictions = pa.table({
    "id": pa.array([0, 1, 2], type=pa.int64()),
    "pred_label": pa.array([5, 0, 4], type=pa.int32()),
    "pred_conf": pa.array([0.97, 0.88, 0.82]),
})
tbl.merge(predictions, on="id")

The original columns and indices are untouched, so existing code that does not reference the new columns continues to work unchanged. New columns become visible to every reader as soon as the operation commits. For column values that require a Python computation (e.g., running a second image encoder over the inline PNG bytes), Lance provides a batch-UDF API in the underlying library — see the Lance data evolution docs for that pattern.

Train

Projection lets a training loop read only the columns each step actually needs. LanceDB tables expose this through Permutation.identity(tbl).select_columns([...]), which plugs straight into the standard torch.utils.data.DataLoader so prefetch, shuffling, and batching behave as in any PyTorch pipeline. Columns added in the Evolve section above cost nothing per batch until they are explicitly projected.

import lancedb
from lancedb.permutation import Permutation
from torch.utils.data import DataLoader

db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
tbl = db.open_table("train")

train_ds = Permutation.identity(tbl).select_columns(["image", "label"])
loader = DataLoader(train_ds, batch_size=256, shuffle=True, num_workers=4)

for batch in loader:
    # batch carries only the projected columns; image_emb stays on disk.
    # decode the PNG bytes, normalize to [0, 1], forward, backward...
    ...

Switching feature sets is a configuration change: passing ["image_emb", "label"] to select_columns(...) on the next run skips PNG decoding entirely and reads only the cached 512-d vectors, which is the right shape for training a linear probe or a lightweight reranker on top of frozen CLIP features.

Versioning

Every mutation to a Lance dataset, whether it adds a column, merges labels, or builds an index, commits a new version. Previous versions remain intact on disk. You can list versions and inspect the history directly from the Hub copy; creating new tags requires a local copy since tags are writes.

import lancedb

db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
tbl = db.open_table("train")

print("Current version:", tbl.version)
print("History:", tbl.list_versions())
print("Tags:", tbl.tags.list())

Once you have a local copy, tag a version for reproducibility:

local_db = lancedb.connect("./mnist-lance/data")
local_tbl = local_db.open_table("train")
local_tbl.tags.create("clip-vitb32-v1", local_tbl.version)

A tagged version can be opened by name, or any version reopened by its number, against either the Hub copy or a local one:

tbl_v1 = db.open_table("train", version="clip-vitb32-v1")
tbl_v5 = db.open_table("train", version=5)

Pinning supports two workflows. A retrieval system locked to clip-vitb32-v1 keeps returning stable results while the dataset evolves in parallel; newly added prediction columns or relabelings do not change what the tag resolves to. A training experiment pinned to the same tag can be rerun later against the exact same digits and labels, so changes in metrics reflect model changes rather than data drift. Neither workflow needs shadow copies or external manifest tracking.

Materialize a subset

Reads from the Hub are lazy, so exploratory queries only transfer the columns and row groups they touch. Mutating operations (Evolve, tag creation) need a writable backing store, and a training loop benefits from a local copy with fast random access. Both can be served by a subset of the dataset rather than the full split. The pattern is to stream a filtered query through .to_batches() into a new local table; only the projected columns and matching row groups cross the wire, and the bytes never fully materialize in Python memory.

import lancedb

remote_db = lancedb.connect("hf://datasets/lance-format/mnist-lance/data")
remote_tbl = remote_db.open_table("train")

batches = (
    remote_tbl.search()
    .where("label IN (4, 9)")
    .select(["id", "image", "label", "label_name", "image_emb"])
    .to_batches()
)

local_db = lancedb.connect("./mnist-4-vs-9")
local_db.create_table("train", batches)

The resulting ./mnist-4-vs-9 is a first-class LanceDB database. Every snippet in the Evolve, Train, and Versioning sections above works against it by swapping hf://datasets/lance-format/mnist-lance/data for ./mnist-4-vs-9.

Source & license

Converted from ylecun/mnist. MNIST is released under the MIT license. The original dataset is by Yann LeCun, Corinna Cortes, and Christopher J.C. Burges.

Citation

@article{lecun1998mnist,
  title={The MNIST database of handwritten digits},
  author={LeCun, Yann and Cortes, Corinna and Burges, CJ},
  url={http://yann.lecun.com/exdb/mnist/},
  year={1998}
}
Downloads last month
55