Datasets:
Tasks:
Other
Modalities:
Time-series
Formats:
parquet
Languages:
English
Size:
10K - 100K
ArXiv:
License:
openwebtext-gemma3-tokenized-1024-activations-layer23 / openwebtext-gemma3-tokenized-1024-activations-layer23.py
| import numpy as np | |
| import glob | |
| import datasets | |
| _DESCRIPTION = """\ | |
| Precomputed hidden state activations from layer 23 of Gemma-3-1B-IT | |
| for the OpenWebText dataset, tokenized with sequence length 1024. | |
| Designed for training a Titans memory layer. | |
| """ | |
| _SHARD_BASE = "shard_[0-9]*.npy" | |
| class OpenwebtextGemma3Tokenized1024ActivationsLayer23(datasets.GeneratorBasedBuilder): | |
| VERSION = datasets.Version("1.0.0") | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=datasets.Features({ | |
| "activations": datasets.Array3D(shape=(1024, 3072), dtype="float32"), | |
| "mask": datasets.Array2D(shape=(1024,), dtype="int32"), | |
| "tokens": datasets.Array2D(shape=(1024,), dtype="int32"), | |
| }), | |
| ) | |
| def _split_generators(self, dl_manager): | |
| all_npy = sorted(glob.glob(_SHARD_BASE)) | |
| shards = [f for f in all_npy | |
| if not f.endswith("_masks.npy") and not f.endswith("_tokens.npy")] | |
| return [datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"shard_files": shards}, | |
| )] | |
| def _generate_examples(self, shard_files): | |
| for shard_path in shard_files: | |
| shard_id = shard_path.split("shard_")[1].split(".npy")[0] | |
| act = np.load(shard_path).astype(np.float32) | |
| mask = np.load(shard_path.replace(".npy", "_masks.npy")) | |
| tokens = np.load(shard_path.replace(".npy", "_tokens.npy")) | |
| for i in range(act.shape[0]): | |
| yield f"{shard_id}_{i}", { | |
| "activations": act[i], | |
| "mask": mask[i], | |
| "tokens": tokens[i], | |
| } | |