k2-quant-eval / fetch /fetch_wikitext2.sh
TitanMamo10's picture
eval ids + harness + pipeline drivers + provenance/run docs
d53b365 verified
Raw History Blame Contribute Delete
2.3 kB
#!/bin/sh
# fetch_wikitext2.sh [DEST] -- get WikiText-2 raw (CC BY-SA 4.0) for calibration + PPL.
#
# DEST/wikitext-2-raw/wiki.train.raw calibration + SC + trace (the pipeline's WIKI)
# DEST/wikitext-2-raw/wiki.test.raw PPL eval (the pipeline's F)
#
# We do NOT redistribute this text (see ../LICENSE-DATA.md). This script does, from the
# canonical Hub dataset repo Salesforce/wikitext, split wikitext-2-raw-v1.
#
# Requires: python3 with huggingface_hub + pyarrow (both in `pip install datasets`).
set -eu
DEST=${1:-.}
DEST=$(mkdir -p "$DEST" && cd "$DEST" && pwd)
python3 - "$DEST" <<'PY'
import os, sys
from huggingface_hub import hf_hub_download
import pyarrow.parquet as pq
dest = os.path.join(sys.argv[1], "wikitext-2-raw")
os.makedirs(dest, exist_ok=True)
for split, fn in (("train", "wiki.train.raw"), ("test", "wiki.test.raw")):
p = hf_hub_download("Salesforce/wikitext", f"wikitext-2-raw-v1/{split}-00000-of-00001.parquet",
repo_type="dataset")
rows = pq.read_table(p).column("text").to_pylist()
# NOTE: the Hub parquet is a whitespace-normalised conversion of the original release
# tarball: per-line leading/trailing spaces and runs of blank lines are collapsed, so this
# file is ~0.10% longer than our .raw copy (blank lines are preserved as separate rows). Same corpus, same content, slightly
# different byte layout -> chunk boundaries (and therefore the last decimals of PPL) differ.
out = os.path.join(dest, fn)
with open(out, "w", encoding="utf-8") as f:
f.write("\n".join(rows))
print(f"{out} {os.path.getsize(out)} bytes {len(rows)} rows")
PY
cat <<'EOF'
Reference: this is the corpus we used, but our exact files are
wiki.train.raw 10940747 bytes sha256 6707892fa3788b5ab9ed78ab5ff37d9fe825f6011a2ad4fcd6a6d467f0e7da57
wiki.test.raw 1290590 bytes sha256 173c87a53759e0201f33e0ccf978e510c2042d7f2cb78229d9a50d79b9e7dd08
(the hashes pin the upstream release layout; the parquet above will NOT match them).
For a bit-identical PPL reproduction, ask us for those two files (CC BY-SA 4.0) or fetch the
original release zip, which is currently unreachable from this endpoint (the Salesforce S3
bucket redirects to a host with a broken certificate, 2026-10-27).
EOF