interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / streams / data / extract.py

21 lines · 1099 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Data preparation only (not the product path): stream the `text` column of FineWeb-Edu parquet
3shards to stdout as length-prefixed documents: u32 little-endian byte length, then UTF-8 bytes.
4Usage: extract.py <shard.parquet> [--skip-docs N] [--max-docs N] [--max-bytes N]
5Prints nothing else on stdout. Run with the pyarrow venv."""
6import sys, struct, argparse
7import pyarrow.parquet as pq
8ap = argparse.ArgumentParser()
9ap.add_argument("shard"); ap.add_argument("--skip-docs", type=int, default=0)
10ap.add_argument("--max-docs", type=int, default=1 << 62); ap.add_argument("--max-bytes", type=int, default=1 << 62)
11a = ap.parse_args()
12out = sys.stdout.buffer
13seen = emitted = nbytes = 0
14for batch in pq.ParquetFile(a.shard).iter_batches(batch_size=2048, columns=["text"]):
15 for t in batch.column(0).to_pylist():
16 seen += 1
17 if seen <= a.skip_docs: continue
18 if emitted >= a.max_docs or nbytes >= a.max_bytes: sys.exit(0)
19 b = t.encode("utf-8")
20 out.write(struct.pack("<I", len(b))); out.write(b)
21 emitted += 1; nbytes += len(b)