Download texttobin.py from qwrt/Swedish1M: direct link, hf CLI and curl.
- Browser
- Download file 276 Bytes
-
https://huggingface.co/qwrt/Swedish1M/resolve/main/texttobin.py
- Command line
-
hf download hf://qwrt/Swedish1M/texttobin.py
-
curl -L -o texttobin.py https://huggingface.co/qwrt/Swedish1M/resolve/main/texttobin.py
276 Bytes
| import numpy as np | |
| # Engångsjobb: läs filen som råa bytes, spara som uint8-array | |
| data = np.fromfile("bigfile.txt", dtype=np.uint8) | |
| # Dela i train/val (t.ex. 99.5/0.5) | |
| n = len(data) | |
| data[: int(n * 0.995)].tofile("train.bin") | |
| data[int(n * 0.995):].tofile("val.bin") |