Dataset Viewer
The dataset viewer is not available for this dataset.
Cannot get the config names for the dataset.
Error code:   ConfigNamesError
Exception:    FileNotFoundError
Message:      Couldn't find any data file at /src/services/worker/juliannunezb/midtrain-mix-5b-gpt2. Couldn't find 'juliannunezb/midtrain-mix-5b-gpt2' on the Hugging Face Hub either: FileNotFoundError: Unable to find 'hf://datasets/juliannunezb/midtrain-mix-5b-gpt2@a57978b353c15996cc42e33776896e416b7fbed7/train.bin' with any supported extension ['.csv', '.tsv', '.json', '.jsonl', '.ndjson', '.parquet', '.geoparquet', '.gpq', '.arrow', '.txt', '.tar', '.xml', '.hdf5', '.h5', '.eval', '.lance', '.blp', '.bmp', '.dib', '.bufr', '.cur', '.pcx', '.dcx', '.dds', '.ps', '.eps', '.fit', '.fits', '.fli', '.flc', '.ftc', '.ftu', '.gbr', '.gif', '.grib', '.png', '.apng', '.jp2', '.j2k', '.jpc', '.jpf', '.jpx', '.j2c', '.icns', '.ico', '.im', '.iim', '.tif', '.tiff', '.jfif', '.jpe', '.jpg', '.jpeg', '.mpg', '.mpeg', '.msp', '.pcd', '.pxr', '.pbm', '.pgm', '.ppm', '.pnm', '.psd', '.bw', '.rgb', '.rgba', '.sgi', '.ras', '.tga', '.icb', '.vda', '.vst', '.webp', '.wmf', '.emf', '.xbm', '.xpm', '.BLP', '.BMP', '.DIB', '.BUFR', '.CUR', '.PCX', '.DCX', '.DDS', '.PS', '.EPS', '.FIT', '.FITS', '.FLI', '.FLC', '.FTC', '.FTU', '.GBR', '.GIF', '.GRIB', '.PNG', '.APNG', '.JP2', '.J2K', '.JPC', '.JPF', '.JPX', '.J2C', '.ICNS', '.ICO', '.IM', '.IIM', '.TIF', '.TIFF', '.JFIF', '.JPE', '.JPG', '.JPEG', '.MPG', '.MPEG', '.MSP', '.PCD', '.PXR', '.PBM', '.PGM', '.PPM', '.PNM', '.PSD', '.BW', '.RGB', '.RGBA', '.SGI', '.RAS', '.TGA', '.ICB', '.VDA', '.VST', '.WEBP', '.WMF', '.EMF', '.XBM', '.XPM', '.aiff', '.au', '.avr', '.caf', '.flac', '.htk', '.svx', '.mat4', '.mat5', '.mpc2k', '.ogg', '.paf', '.pvf', '.raw', '.rf64', '.sd2', '.sds', '.ircam', '.voc', '.w64', '.wav', '.nist', '.wavex', '.wve', '.xi', '.mp3', '.opus', '.3gp', '.3g2', '.avi', '.asf', '.flv', '.mp4', '.mov', '.m4v', '.mkv', '.webm', '.f4v', '.wmv', '.wma', '.ogm', '.mxf', '.nut', '.AIFF', '.AU', '.AVR', '.CAF', '.FLAC', '.HTK', '.SVX', '.MAT4', '.MAT5', '.MPC2K', '.OGG', '.PAF', '.PVF', '.RAW', '.RF64', '.SD2', '.SDS', '.IRCAM', '.VOC', '.W64', '.WAV', '.NIST', '.WAVEX', '.WVE', '.XI', '.MP3', '.OPUS', '.3GP', '.3G2', '.AVI', '.ASF', '.FLV', '.MP4', '.MOV', '.M4V', '.MKV', '.WEBM', '.F4V', '.WMV', '.WMA', '.OGM', '.MXF', '.NUT', '.pdf', '.PDF', '.nii', '.NII', '.zip', '.idx', '.manifest', '.txn']
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/dataset/config_names.py", line 66, in compute_config_names_response
                  config_names = get_dataset_config_names(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/inspect.py", line 161, in get_dataset_config_names
                  dataset_module = dataset_module_factory(
                                   ^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/load.py", line 1203, in dataset_module_factory
                  raise FileNotFoundError(
              FileNotFoundError: Couldn't find any data file at /src/services/worker/juliannunezb/midtrain-mix-5b-gpt2. Couldn't find 'juliannunezb/midtrain-mix-5b-gpt2' on the Hugging Face Hub either: FileNotFoundError: Unable to find 'hf://datasets/juliannunezb/midtrain-mix-5b-gpt2@a57978b353c15996cc42e33776896e416b7fbed7/train.bin' with any supported extension ['.csv', '.tsv', '.json', '.jsonl', '.ndjson', '.parquet', '.geoparquet', '.gpq', '.arrow', '.txt', '.tar', '.xml', '.hdf5', '.h5', '.eval', '.lance', '.blp', '.bmp', '.dib', '.bufr', '.cur', '.pcx', '.dcx', '.dds', '.ps', '.eps', '.fit', '.fits', '.fli', '.flc', '.ftc', '.ftu', '.gbr', '.gif', '.grib', '.png', '.apng', '.jp2', '.j2k', '.jpc', '.jpf', '.jpx', '.j2c', '.icns', '.ico', '.im', '.iim', '.tif', '.tiff', '.jfif', '.jpe', '.jpg', '.jpeg', '.mpg', '.mpeg', '.msp', '.pcd', '.pxr', '.pbm', '.pgm', '.ppm', '.pnm', '.psd', '.bw', '.rgb', '.rgba', '.sgi', '.ras', '.tga', '.icb', '.vda', '.vst', '.webp', '.wmf', '.emf', '.xbm', '.xpm', '.BLP', '.BMP', '.DIB', '.BUFR', '.CUR', '.PCX', '.DCX', '.DDS', '.PS', '.EPS', '.FIT', '.FITS', '.FLI', '.FLC', '.FTC', '.FTU', '.GBR', '.GIF', '.GRIB', '.PNG', '.APNG', '.JP2', '.J2K', '.JPC', '.JPF', '.JPX', '.J2C', '.ICNS', '.ICO', '.IM', '.IIM', '.TIF', '.TIFF', '.JFIF', '.JPE', '.JPG', '.JPEG', '.MPG', '.MPEG', '.MSP', '.PCD', '.PXR', '.PBM', '.PGM', '.PPM', '.PNM', '.PSD', '.BW', '.RGB', '.RGBA', '.SGI', '.RAS', '.TGA', '.ICB', '.VDA', '.VST', '.WEBP', '.WMF', '.EMF', '.XBM', '.XPM', '.aiff', '.au', '.avr', '.caf', '.flac', '.htk', '.svx', '.mat4', '.mat5', '.mpc2k', '.ogg', '.paf', '.pvf', '.raw', '.rf64', '.sd2', '.sds', '.ircam', '.voc', '.w64', '.wav', '.nist', '.wavex', '.wve', '.xi', '.mp3', '.opus', '.3gp', '.3g2', '.avi', '.asf', '.flv', '.mp4', '.mov', '.m4v', '.mkv', '.webm', '.f4v', '.wmv', '.wma', '.ogm', '.mxf', '.nut', '.AIFF', '.AU', '.AVR', '.CAF', '.FLAC', '.HTK', '.SVX', '.MAT4', '.MAT5', '.MPC2K', '.OGG', '.PAF', '.PVF', '.RAW', '.RF64', '.SD2', '.SDS', '.IRCAM', '.VOC', '.W64', '.WAV', '.NIST', '.WAVEX', '.WVE', '.XI', '.MP3', '.OPUS', '.3GP', '.3G2', '.AVI', '.ASF', '.FLV', '.MP4', '.MOV', '.M4V', '.MKV', '.WEBM', '.F4V', '.WMV', '.WMA', '.OGM', '.MXF', '.NUT', '.pdf', '.PDF', '.nii', '.NII', '.zip', '.idx', '.manifest', '.txn']

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Midtrain-Mix-5B-GPT2

A 5-billion-token high-quality mid-training mix, pre-tokenized with the GPT-2 BPE tokenizer (vocab=50257) and packed into flat np.memmap-ready uint16 binary files. Drop it straight into any GPT-2-vocab pretrain trainer for continued pretraining / mid-training / annealing of a model that's already seen a generic web corpus.

What is mid-training and why does it matter?

After a standard pretrain pass on web data (FineWeb, RedPajama, DCLM, etc.), modern LM recipes do a second, shorter pass with a lower LR on a higher quality data mix. The technique goes by several names across labs:

Lab Name
Meta (Llama-3) "annealing phase"
DeepSeek (V3 / R1) "reasoning corpus continued pretraining"
Allen AI (OLMo) "stage-2 pretraining"
Hugging Face (SmolLM2) "mid-training"

The pattern is consistent: filter heavily for factual / educational / mathy content, shrink the LR an order of magnitude, run for ~5–20% of the original pretrain budget. The model bakes more knowledge into its weights without forgetting what it already learned.

This dataset is that "premium mix" for a small GPT-2-vocab model.

Overview

  • Total tokens: ~5 B (intended for ~1 epoch over the data)
  • Tokenizer: tiktoken.get_encoding("gpt2") — vocab 50257, EOT id 50256
  • Format: flat uint16 bins, ready for np.memmap
  • Sources (proportions optimized for knowledge density at small scale):
    • 70 % FineWeb-Edu (HuggingFaceFW/fineweb-edu, sample-10BT) — web filtered for educational value by a classifier trained against Llama-3-70B annotations
    • 20 % Wikipedia (en) (wikimedia/wikipedia 20231101.en) — dense factual prose
    • 10 % Open-Web-Math (open-web-math/open-web-math) — math + arXiv + LaTeX
  • No code in this mix. Reason: at 50M-200M parameter scale, code is poorly utilized; SFT corpora like smoltalk already include code via apigen-80k and self-oss-instruct. For larger models, add a code source separately.

Dataset Statistics

train val
tokens ~4.97 B ~25 M
size (uint16) ~9.94 GB ~50 MB
val fraction 0.005

(Exact numbers in stats.json after the build completes.)

Train/val split: per-document dice roll (seed 42) at VAL_FRAC = 0.005. The val set is representative of the mix (i.e. sampled the same way), not held out from a single source.

Schema

The format is dead simple — two flat files:

train.bin   uint16   concatenated token ids, one big stream, no separators
val.bin     uint16   same format, validation tokens

Documents are concatenated without EOT separators (the trainer's random window sampler will sometimes draw windows that span document boundaries — that's acceptable for mid-training and often helpful for context-mixing).

Loading

Standard np.memmap (memory-mapped, recommended)

import numpy as np
train = np.memmap("train.bin", dtype=np.uint16, mode="r")
val   = np.memmap("val.bin",   dtype=np.uint16, mode="r")
print(f"train: {len(train)/1e9:.2f} B tokens, val: {len(val)/1e6:.1f} M tokens")

# Sample a random training window of BLOCK_SIZE tokens (pretrain-style):
BLOCK_SIZE = 2048
ix = np.random.randint(0, len(train) - BLOCK_SIZE - 1)
window = np.asarray(train[ix:ix+BLOCK_SIZE+1], dtype=np.int64)
x = torch.from_numpy(window[:-1])   # shape (BLOCK_SIZE,)
y = torch.from_numpy(window[1:])    # next-token targets

Decode a sample to verify

import tiktoken
tok = tiktoken.get_encoding("gpt2")
sample_ids = list(train[1_000_000:1_000_500])  # 500 tokens somewhere in the middle
print(tok.decode(sample_ids))

How to use for mid-training

After your generic pretrain, resume from your pretrain ckpt with:

  • LR: 10× lower than pretrain peak. If pretrain was at 1.5e-3, run midtrain at 1.5e-4 with cosine to 10%.
  • WARMUP: short (100–300 steps) — model is already warmed up.
  • N_ITER: target ~1 epoch over this data. For block=2048, batch=16:
    N_ITER = 5e9 / (2048 * 16) ≈ 152,587 steps
    
  • OPTIMIZER: fresh (drop pretrain momentum). Architecture identical to pretrain.
  • SAMPLE_MODE: shuffled-no-repeat (each window seen exactly once per epoch).

Example reference launcher (the local50m project uses this pattern):

MODE=pretrain \
DATA_DIR=/path/to/midtrain \
RESUME_FROM=/path/to/pretrain_final.pt \
RESUME_OPTIM=0 RESUME_STEP=0 \
LR=1.5e-4 MUON_LR=4.5e-3 MIN_LR_RATIO=0.1 WARMUP_STEPS=200 \
N_ITER=150000 CKPT_INTERVAL=10000 BLOCK_SIZE=2048 BATCH_SIZE=16 \
SAMPLE_MODE=shuffled \
HF_CHECKPOINT_REPO=user/your-midtrain-model \
python3 local50m_train.py

Expected behavior on a well-pretrained model:

  • Val loss drops measurably in the first 10K steps (knowledge consolidation).
  • Plateaus around the cosine min by ~120K steps.
  • Total wall-clock: ~6 h on an RTX 5090, ~$3.

Reproducing

HF_TOKEN=... python3 prepare_midtrain.py                    # local only
HF_TOKEN=... UPLOAD_TO=user/repo PRIVATE=0 python3 prepare_midtrain.py
SMOKE=1 python3 prepare_midtrain.py                         # 10M-token smoke test
N_PROC=16 python3 prepare_midtrain.py                       # parallel tokenize

Build details:

  • Built: 2026-05-13 UTC, on a single M1 Max (~3 h for 5 B tokens, 8 workers)
  • Script: prepare_midtrain.py
  • Source dataset commits: latest at build time
    • HuggingFaceFW/fineweb-edu (sample-10BT subset)
    • wikimedia/wikipedia (20231101.en)
    • open-web-math/open-web-math

Sanity checks performed

  • All token ids in [0, 50256] (GPT-2 BPE valid range).
  • Decode round-trip of random 500-token windows reads as natural English / math / code.
  • Per-source token counts match target proportions within ±2%.

Pipeline context

This dataset slots in as the mid-training corpus in a full modern LM pipeline:

juliannunezb/mixed-pretrain-10b-gpt2          ← generic pretrain (9.8 B tok)
   ↓ pretrain
juliannunezb/midtrain-mix-5b-gpt2     ←━━ this dataset (5 B tok, premium)
   ↓ mid-training
juliannunezb/smoltalk-gpt2-sft                ← SFT corpus (1 M conversations)
   ↓ SFT
juliannunezb/ultrafeedback-gpt2-dpo           ← preference pairs (60K)
   ↓ DPO
[optional: GRPO on verifiable tasks]

License

This dataset (tokenized stream): Apache-2.0, since all three component datasets are Apache-2.0 or CC-BY-SA compatible:

  • FineWeb-Edu: Open Data Commons By Attribution 1.0
  • Wikipedia (en): CC-BY-SA-3.0 + GFDL
  • Open-Web-Math: Open Data Commons By Attribution 1.0

See each upstream dataset card for full provenance.

Citation

If you use this dataset, please cite the upstream sources:

@misc{lozhkov2024fineweb-edu,
  author = {Lozhkov, Anton and Ben Allal, Loubna and von Werra, Leandro and Wolf, Thomas},
  title  = {FineWeb-Edu: the Finest Collection of Educational Content the Web Has to Offer},
  year   = {2024},
  url    = {https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu}
}
@misc{paster2023openwebmath,
  title  = {OpenWebMath: An Open Dataset of High-Quality Mathematical Web Text},
  author = {Paster, Keiran and Dos Santos, Marco and Azerbayev, Zhangir and Ba, Jimmy},
  year   = {2023},
  eprint = {2310.06786},
  archivePrefix = {arXiv}
}

And for this packaging:

@misc{midtrain_mix_5b_gpt2_2026,
  title  = {Midtrain-Mix-5B-GPT2: a premium mid-training mix for small GPT-2-vocab models},
  author = {Julián Núñez},
  year   = {2026},
  publisher = {Hugging Face},
  url    = {https://huggingface.co/datasets/juliannunezb/midtrain-mix-5b-gpt2}
}

Known Limitations

  • English-only. All three component sources are English-centric.
  • GPT-2 BPE only. If your target model uses Llama or NeoX BPE, you need to re-tokenize from raw sources.
  • 5 B tokens is a lot for a small model, not much for a big one. Best for the 50M–500M param range; for 1B+ models you'd want ~50 B of similar quality.
  • Web filtering imperfect. FineWeb-Edu's classifier biases toward formal / academic prose — undersamples engineering / how-to / hobbyist content. If you want broader coverage, mix in some unfiltered fineweb at low weight.
  • No domain-specific code in the mix. Use a separate code mix (StarCoderData, the-stack) for code-aware models.
Downloads last month
60

Paper for juliannunezb/midtrain-mix-5b-gpt2