from __future__ import annotations import json import random from pathlib import Path import numpy as np import torch ROOT = Path(__file__).resolve().parents[1] DATA_DIR = ROOT / 'data' ARTIFACT_DIR = ROOT / 'artifacts' def load_jsonl(path: str | Path) -> list[dict]: rows = [] with Path(path).open(encoding='utf-8') as handle: for line in handle: line = line.strip() if line: rows.append(json.loads(line)) return rows def set_seed(seed: int) -> None: random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) if torch.cuda.is_available(): torch.cuda.manual_seed_all(seed)