Datasets:
Tasks:
Other
Modalities:
Time-series
Formats:
parquet
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Update README with Parquet format docs
Browse files17 unmodified lines1819202122232425262728293031323334353637383940414243444546473 unmodified lines5152535455565758596061626364656667686970717273742 unmodified lines777879808182838485868788899091929394959697989910010110210310410510617 unmodified linesPrecomputed hidden state activations before layer 23 of [Gemma-3-1B-IT](https://huggingface.co/google/gemma-3-1b-it) for the [OpenWebText](https://huggingface.co/datasets/Skylion007/openwebtext) dataset, tokenized with sequence length 1024.Designed for training a **[Titans](https://arxiv.org/abs/2501.00663)** memory layer replaced layer 23 of Gemma 3.## Dataset StructureEach shard contains pre-computed forward pass outputs up to layer 23:| File | Shape | Dtype | Description ||------|-------|-------|-------------|| `shard_NNNNNN.npy` | `(64, 1024, 3072)` | `bfloat16` | Hidden state activations || `shard_NNNNNN_masks.npy` | `(64, 1024)` | `int32` | Attention masks (1=real, 0=pad) || `shard_NNNNNN_tokens.npy` | `(64, 1024)` | `int32` | Token IDs |- **Shards:** 1121 (000000–001120)- **Examples per shard:** 64- **Total examples:** ~71,744- **Sequence length:** 1024- **Hidden dimension:** 3072 (Gemma-3-1B embed_dim)- **Source model:** `google/gemma-3-1b-it`- **Source dataset:** `veriga/openwebtext-gemma3-tokenized-1024`- **Total size:** ~153 GB## How It Was CreatedActivations were computed using a truncated forward pass through the first 23 Gemma 3 transformer layers. The process:1. Load OpenWebText tokens from `veriga/openwebtext-gemma3-tokenized-1024`2. Pad/truncate to 1024 tokens, generate attention masks3 unmodified linesSee the [precomputation notebook](https://github.com/andrew-veriga/Titans_jax/blob/main/colabs/Precompute_Activations_Gemma3_GPU.ipynb) for full details.## Loading the Dataset```pythonfrom datasets import load_datasetds = load_dataset("veriga/openwebtext-gemma3-tokenized-1024-activations-layer23", split="train")```Each example contains:```python{"activations": np.ndarray, # shape (1024, 3072), float32 (cast from bfloat16)"mask": np.ndarray, # shape (1024,), int32"tokens": np.ndarray, # shape (1024,), int32}```### Streaming (recommended for large datasets)```pythonds = load_dataset(2 unmodified linesstreaming=True)for example in ds:activations = example["activations"] # (1024, 3072)mask = example["mask"] # (1024,)tokens = example["tokens"] # (1024,)# Use for Titans training...```### Manual loading (without HF datasets)```pythonimport numpy as npshard_idx = 0activations = np.load(f"shard_{shard_idx:06d}.npy") # (64, 1024, 3072), bfloat16mask = np.load(f"shard_{shard_idx:06d}_masks.npy") # (64, 1024), int32tokens = np.load(f"shard_{shard_idx:06d}_tokens.npy") # (64, 1024), int32```## Use Case: Titans Memory LayerThis dataset is intended for training a [Titans](https://arxiv.org/abs/2501.00663) long-term memory module to be inserted instead of layer 23 of Gemma 3. The precomputed activations allow training the memory layer independently without running the full model forward pass.## Notes- Activations are stored in `bfloat16`; the HF Datasets loader casts them to `float32` for compatibility- Padding positions in activations are zeroed out via attention mask multiplication- The `metadata.json` file contains `{"next_shard": 1120}` used for resume during precomputation17 unmodified lines18192021222324252627282930313233343536373839404142434445464748495051525354553 unmodified lines596061626364656667686970717273747576777879808182838485862 unmodified lines899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914017 unmodified linesPrecomputed hidden state activations before layer 23 of [Gemma-3-1B-IT](https://huggingface.co/google/gemma-3-1b-it) for the [OpenWebText](https://huggingface.co/datasets/Skylion007/openwebtext) dataset, tokenized with sequence length 1024.Designed for training a **[Titans](https://arxiv.org/abs/2501.00663)** memory layer that replaces layer 23 of Gemma 3.## Dataset StructureEach example contains the inputs to layer 23:| Field | Shape | Dtype | Description ||-------|-------|-------|-------------|| `activations` | `(1024, 1152)` | `float32` | Hidden state activations (cast from bfloat16) || `mask` | `(1024,)` | `int32` | Attention mask (1=real token, 0=pad) || `tokens` | `(1024,)` | `int32` | Token IDs |- **Total examples:** ~71,744- **Examples per NPY shard:** 64- **Examples per Parquet file:** 640 (10 NPY shards)- **Sequence length:** 1024- **Hidden dimension:** 1152 (Gemma-3-1B embed_dim)- **Source model:** `google/gemma-3-1b-it`- **Source dataset:** `veriga/openwebtext-gemma3-tokenized-1024`### Files| Format | Files | Location ||--------|-------|----------|| Parquet (recommended) | 113 files | `data/train-NNNNNN-NNNNNN.parquet` || NPY (original) | 3363 files | `shard_NNNNNN.npy`, `shard_NNNNNN_masks.npy`, `shard_NNNNNN_tokens.npy` |Parquet files use **ZSTD compression** (level 3) and store activations as a flat `fixed_size_list<float32>[1179648]` (reshape to `1024 × 1152` after loading).## How It Was CreatedActivations were computed using a truncated forward pass through the first 23 Gemma 3 transformer layers:1. Load OpenWebText tokens from `veriga/openwebtext-gemma3-tokenized-1024`2. Pad/truncate to 1024 tokens, generate attention masks3 unmodified linesSee the [precomputation notebook](https://github.com/andrew-veriga/Titans_jax/blob/main/colabs/Precompute_Activations_Gemma3_GPU.ipynb) for full details.Parquet conversion: [Convert_NPY_to_Parquet.ipynb](https://github.com/andrew-veriga/Titans_jax/blob/main/colabs/Convert_NPY_to_Parquet.ipynb)## Loading the Dataset### Standard (loads Parquet)```pythonfrom datasets import load_datasetds = load_dataset("veriga/openwebtext-gemma3-tokenized-1024-activations-layer23", split="train")example = ds[0]activations = example["activations"] # list of 1179648 floatsmask = example["mask"] # list of 1024 intstokens = example["tokens"] # list of 1024 ints# Reshape activationsimport numpy as npact = np.array(activations, dtype=np.float32).reshape(1024, 1152)```### Streaming (recommended — no download)```pythonds = load_dataset(2 unmodified linesstreaming=True)import numpy as npfor example in ds:act = np.array(example["activations"], dtype=np.float32).reshape(1024, 1152)mask = np.array(example["mask"])tokens = np.array(example["tokens"])# Use for Titans training...```### Direct Parquet access (no HF datasets)```pythonimport pyarrow.parquet as pqimport numpy as np# From HuggingFace Hubfrom huggingface_hub import hf_hub_downloadpath = hf_hub_download(repo_id="veriga/openwebtext-gemma3-tokenized-1024-activations-layer23",filename="data/train-000000-000009.parquet",repo_type="dataset",)table = pq.read_table(path)row = table.slice(0, 1).to_pydict()act = np.array(row["activations"][0], dtype=np.float32).reshape(1024, 1152)mask = np.array(row["mask"][0])tokens = np.array(row["tokens"][0])```### Original NPY files```pythonimport jax.numpy as jnp # or use ml_dtypes for np.load with bfloat16import numpy as npactivations = np.array(jnp.load("shard_000000.npy"), dtype=np.float32) # (64, 1024, 1152)mask = np.load("shard_000000_masks.npy") # (64, 1024)tokens = np.load("shard_000000_tokens.npy") # (64, 1024)```## Use Case: Titans Memory LayerThis dataset provides inputs for training a [Titans](https://arxiv.org/abs/2501.00663) long-term memory module that replaces layer 23 of Gemma 3. The precomputed activations allow training the memory layer independently without running the full model forward pass through the first 22 layers.## Notes- Original activations stored in `bfloat16` (NPY); Parquet cast to `float32`- Padding positions in activations are zeroed out via attention mask multiplication- The first token in each sequence is the BOS token (ID=2)
README.md+66-32