Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

TinyStories — BPE8192 (pre-tokenized)

A pre-tokenized version of the TinyStories V2 (GPT-4) corpus, encoded with a byte-pair-encoding (BPE) tokenizer trained on the dataset itself with a target vocabulary size of 8192.

The token streams are stored as flat int32 NumPy arrays, ready to be memory-mapped and sliced into context windows for training small language models. Stories are separated by a single <eos> token (id 1).

Files

File Description
tinystories.BPE8192.train.npy Tokenized train split: 529M tokens as a 1-D int32 array (2.1 GB).
tinystories.BPE8192.valid.npy Tokenized validation split: 5.3M tokens as a 1-D int32 array (21 MB).
tinystories.BPE8192.tokenizer.json The trained 🤗 tokenizers BPE tokenizer (load with Tokenizer.from_file).
tinystories.BPE8192.meta.json Metadata: vocab size, special-token ids, tokenizer filename, split sizes.

meta.json contents

{
  "vocab_size": 8192,
  "eos_token_id": 1,
  "unk_token_id": 0,
  "tokenizer_file": "tinystories/tinystories.BPE8192.tokenizer.json",
  "train_size": 529209187,
  "valid_size": 5343921
}

Tokenizer details

  • Model: BPE with [UNK] as the unknown token.
  • Pre-tokenizer: Whitespace (merges never cross whitespace/word boundaries).
  • Special tokens: [UNK] (id 0), <eos> (id 1).
  • Vocabulary size: 8192 (target; the trainer was given vocab_size=8192).

Each story was encoded independently and concatenated with a trailing <eos> (id 1) to delimit document boundaries in the flat token stream.

Usage

import json
import numpy as np
from tokenizers import Tokenizer
from huggingface_hub import hf_hub_download

REPO_ID = "fracagnetta/tinystories.BPE8192"

# --- metadata ---
meta_path = hf_hub_download(REPO_ID, "tinystories.BPE8192.meta.json", repo_type="dataset")
with open(meta_path) as f:
    meta = json.load(f)
print(meta)  # vocab_size, eos_token_id, unk_token_id, tokenizer_file, train/valid sizes

# --- tokenizer ---
tok_path = hf_hub_download(REPO_ID, "tinystories.BPE8192.tokenizer.json", repo_type="dataset")
tokenizer = Tokenizer.from_file(tok_path)

# --- token arrays (memory-mapped to avoid loading 2 GB into RAM) ---
train_path = hf_hub_download(REPO_ID, "tinystories.BPE8192.train.npy", repo_type="dataset")
valid_path = hf_hub_download(REPO_ID, "tinystories.BPE8192.valid.npy", repo_type="dataset")

train = np.load(train_path, mmap_mode="r")
valid = np.load(valid_path, mmap_mode="r")

print(len(train), len(valid))             # 529209187  5343921

# decode the first story of the validation split
print(tokenizer.decode(valid[:128].tolist()))

## Reproduction

The tokenizer is trained on the concatenated train+valid stories (split on `<|endoftext|>`),
then each split is encoded and saved as an `int32` `.npy` array with `<eos>` separators.

## License

Derived from [roneneldan/TinyStories](https://huggingface.co/datasets/roneneldan/TinyStories);
please follow the upstream dataset's license and terms.
Downloads last month
87