"""Validate published tokenized JSONL and build a local PyTorch cache.""" import argparse import gzip import json import math from pathlib import Path import torch def load_rows(path): source=Path(path) opener=gzip.open if source.suffix=='.gz' else open rows=[] with opener(source,'rt',encoding='utf-8') as stream: for number,line in enumerate(stream,1): row=json.loads(line) ids,markers,target=row['ids'],row['markers'],row['target'] if not ids or any(type(x) is not int or x<0 for x in ids): raise ValueError(f'line {number}: invalid token IDs') if len(markers)!=len(target) or len(target)<2 or any(type(x) is not int or not 0<=x