Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/streams/data/extract.py # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 3 shards to stdout as length-prefixed documents: u32 little-endian byte length, then UTF-8 bytes. 4 Usage: extract.py [--skip-docs N] [--max-docs N] [--max-bytes N] 5 Prints nothing else on stdout. Run with the pyarrow venv.""" 6 import sys, struct, argparse 7 import pyarrow.parquet as pq 8 ap = argparse.ArgumentParser() 9 ap.add_argument("shard"); ap.add_argument("--skip-docs", type=int, default=0) 10 ap.add_argument("--max-docs", type=int, default=1 << 62); ap.add_argument("--max-bytes", type=int, default=1 << 62) 11 a = ap.parse_args() 12 out = sys.stdout.buffer 13 seen = emitted = nbytes = 0 14 for 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("