"""Данные для Elyon-LM: токены лежат в .bin (uint16), батчи берутся случайными окнами.""" from __future__ import annotations import numpy as np import torch def load_bin(path: str) -> np.ndarray: return np.memmap(path, dtype=np.uint16, mode="r") def get_batch(data: np.ndarray, batch_size: int, ctx: int, rng: np.random.Generator): ix = rng.integers(0, len(data) - ctx - 1, size=batch_size) x = np.stack([data[i:i + ctx] for i in ix]).astype(np.int64) y = np.stack([data[i + 1:i + 1 + ctx] for i in ix]).astype(np.int64) return torch.from_numpy(x), torch.from_numpy(y)