| --- |
| language: |
| - en |
| license: other |
| task_categories: |
| - text-classification |
| - feature-extraction |
| tags: |
| - regmix |
| - embeddings |
| - clustering |
| - stella |
| size_categories: |
| - 100K<n<1M |
| --- |
| |
| # RegMix Data Sample (Stella Embeddings) |
|
|
| Mirror of [`sail/regmix-data-sample`](https://huggingface.co/datasets/sail/regmix-data-sample) with precomputed **1024-dim L2-normalized** embeddings from [`Marqo/dunzhang-stella_en_400M_v5`](https://huggingface.co/Marqo/dunzhang-stella_en_400M_v5). |
|
|
| ## Dataset Description |
|
|
| This dataset preserves the original RegMix domain JSONL text and adds Stella embeddings organized for downstream clustering and mixture analysis. |
|
|
| - **Source**: sail/regmix-data-sample |
| - **Embedding model**: Marqo/dunzhang-stella_en_400M_v5 |
| - **Embedding dim**: 1024 |
| - **Max token length**: 512 |
| - **Pooling**: mean over token hidden states |
| - **Normalization**: L2 |
| - **Total rows**: 2,345,364 |
| |
| ### Domains |
| |
| - `train/arxiv`: 79,387 rows |
| - `train/dm_mathematics`: 64,147 rows |
| - `train/enron_emails`: 30,905 rows |
| - `train/europarl`: 4,348 rows |
| - `train/freelaw`: 169,944 rows |
| - `train/github`: 300,000 rows |
| - `train/gutenberg_pg_19`: 2,276 rows |
| - `train/hackernews`: 52,544 rows |
| - `train/nih_exporter`: 58,972 rows |
| - `train/philpapers`: 2,024 rows |
| - `train/pile_cc`: 300,000 rows |
| - `train/pubmed_abstracts`: 300,000 rows |
| - `train/pubmed_central`: 150,000 rows |
| - `train/stackexchange`: 84,651 rows |
| - `train/ubuntu_irc`: 623 rows |
| - `train/uspto_backgrounds`: 300,000 rows |
| - `train/wikipedia_en`: 265,170 rows |
| - `validation/arxiv`: 2,406 rows |
| - `validation/dm_mathematics`: 1,922 rows |
| - `validation/enron_emails`: 1,010 rows |
| - `validation/europarl`: 157 rows |
| - `validation/freelaw`: 5,101 rows |
| - `validation/github`: 18,195 rows |
| - `validation/gutenberg_pg_19`: 80 rows |
| - `validation/hackernews`: 1,632 rows |
| - `validation/nih_exporter`: 1,884 rows |
| - `validation/philpapers`: 64 rows |
| - `validation/pile_cc`: 52,790 rows |
| - `validation/pubmed_abstracts`: 29,895 rows |
| - `validation/pubmed_central`: 5,911 rows |
| - `validation/stackexchange`: 30,378 rows |
| - `validation/ubuntu_irc`: 22 rows |
| - `validation/uspto_backgrounds`: 11,415 rows |
| - `validation/wikipedia_en`: 17,511 rows |
|
|
| ## Schema |
|
|
| Each parquet shard under `data/{split}/{domain}.parquet` contains: |
|
|
| | Column | Type | Description | |
| |---|---|---| |
| | `example_id` | int64 | Stable join key | |
| | `split` | string | `train` or `validation` | |
| | `domain` | string | RegMix domain name | |
| | `source_file` | string | Original JSONL filename | |
| | `line_idx` | int32 | Line index in source file | |
| | `text` | string | Original document text | |
| | `text_char_len` | int32 | Character length of text | |
| | `embedding` | list[float32] | L2-normalized Stella vector | |
|
|
| `indices/global_index.parquet` maps each `example_id` to its shard path and row index. |
|
|
| ## Usage |
|
|
| ### Load with Hugging Face Datasets |
|
|
| ```python |
| from datasets import load_dataset |
| import numpy as np |
| |
| ds = load_dataset("quinnlue/regmix-data-sample-stella", split="train") |
| emb = np.stack(ds["embedding"], dtype=np.float32) # [N, 1024] |
| ids = np.array(ds["example_id"], dtype=np.int64) |
| domains = ds["domain"] |
| ``` |
|
|
| ### Load a single domain |
|
|
| ```python |
| from datasets import load_dataset |
| |
| arxiv = load_dataset( |
| "quinnlue/regmix-data-sample-stella", |
| data_files={"train": "data/train/arxiv.parquet"}, |
| split="train", |
| ) |
| ``` |
|
|
| ### Clustering starter (spherical k-means) |
|
|
| ```python |
| from datasets import load_dataset |
| import numpy as np |
| from sklearn.cluster import KMeans |
| |
| ds = load_dataset("quinnlue/regmix-data-sample-stella", split="train") |
| emb = np.stack(ds["embedding"], dtype=np.float32) |
| ids = np.array(ds["example_id"], dtype=np.int64) |
| |
| kmeans = KMeans(n_clusters=128, n_init=10, random_state=0) |
| cluster_ids = kmeans.fit_predict(emb) |
| |
| assignments = {int(example_id): int(cluster_id) for example_id, cluster_id in zip(ids, cluster_ids)} |
| ``` |
|
|
| ## Citation |
|
|
| If you use this dataset, please cite the RegMix paper: |
|
|
| ```bibtex |
| @article{liu2024regmix, |
| title={RegMix: Data Mixture as Regression for Language Model Pre-training}, |
| author={Liu, Qian and Zheng, Xiaosen and Muennighoff, Niklas and Zeng, Guangtao and Dou, Longxu and Pang, Tianyu and Jiang, Jing and Lin, Min}, |
| journal={arXiv preprint arXiv:2407.01492}, |
| year={2024} |
| } |
| ``` |
|
|