File size: 14,222 Bytes
114c076
2b69a6f
 
 
c268d56
2b69a6f
 
 
ffda3a0
2b69a6f
 
 
 
 
 
 
 
 
114c076
af5cc74
2b69a6f
 
c268d56
 
2b69a6f
 
 
 
 
 
 
8c384a2
 
2b69a6f
8c384a2
2b69a6f
 
8c384a2
2b69a6f
 
 
 
 
 
 
 
8c384a2
2b69a6f
 
 
 
 
 
 
 
 
ffda3a0
 
8c384a2
ffda3a0
2b69a6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c384a2
 
 
ffda3a0
8c384a2
ffda3a0
 
8c384a2
 
 
 
 
 
 
 
ffda3a0
 
8c384a2
 
ffda3a0
8c384a2
ffda3a0
 
2b69a6f
 
 
 
 
 
 
 
 
 
8c384a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b69a6f
 
 
 
 
 
 
 
 
 
 
 
 
 
ffda3a0
 
 
2b69a6f
 
 
8c384a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b69a6f
 
 
 
 
 
 
c268d56
8c384a2
2b69a6f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---
pretty_name: docs1
language:
- en
license: cc-by-nc-nd-4.0
task_categories:
- text-generation
size_categories:
- 1M<n<10M
tags:
- long-context
- documents
- continual-learning
configs:
- config_name: default
  data_files:
  - split: train
    path: data/*/*.parquet
---

# docs1

*The dataset of high-quality, diverse, factual documents for in-context use.*

**docs1** is AlphaQualia's base corpus of documents for in-context use. It contains factual, high-quality English
documents of 1K–32K tokens, sorted into 31 length buckets of 1,024 [MiniCPM5-2B](https://huggingface.co/openbmb/MiniCPM5-2B)
tokens each. It is the shared starting point for every downstream dataset (questions, reconstructions, tool tasks,
teacher generations). Those datasets refer to documents by `id` and never copy them.

| | |
|---|---|
| Documents | **2,889,645** |
| Tokens (MiniCPM5-2B) | **34.81B** |
| Length range | 1,024 – 32,768 tokens, 31 buckets |
| Docs per bucket | 25,560 (longest) to 181,521 (shortest) |
| Sources | 23 public Hub datasets |
| Exact duplicates removed | 79,462 |
| Version | v1.1 (stage 1: curation + light cleanup), built 2026-10-14 |

![Documents per length bucket](assets/docs_per_bucket.png)

## Usage

```python
from datasets import load_dataset

# Everything (streams; about 34.81B tokens of text)
ds = load_dataset("alpha-qualia/docs1", split="train", streaming=True)

# One length bucket: 8,192–9,215 tokens
ds = load_dataset("alpha-qualia/docs1", data_files="data/b07_8192-9215/*.parquet", split="train")

# A length range, by exact token count
ds = ds.filter(lambda r: 8500 <= r["length_tokens_minicpm"] <= 9000)
```

Short documents are far more common than long ones (see the figure), so for a **uniform length
distribution**, sample the same number of documents from every bucket folder. Every bucket has at least
25,560.

Files are stored as `data/b{NN}_{low}-{high}/part-*.parquet`, so a curriculum (short first, then long) can read
whole buckets. Rows are shuffled within each bucket.

## Schema

| Field | Type | Description |
|---|---|---|
| `id` | string (UUID) | Stable document ID: UUIDv5 of `source repo : source row id` (plus the character span for segments). A rebuild gives the same IDs. |
| `created_at` | timestamp (UTC) | When the document was added to docs1. |
| `source_type` | string | The Hub dataset it came from (e.g. `HuggingFaceFW/finepdfs-edu`), or `original` for documents we write (later stages). |
| `metadata` | string (JSON) | Source fields such as `url`, `title`, `license`, `repo`, `path`, plus `source_file`. Segments add `parent_id`, `segment`, `char_span`. |
| `content` | string | The document text, unchanged except for segment cuts. |
| `length_tokens_minicpm` | int32 | Exact token count with the MiniCPM5-2B tokenizer (no special tokens). |
| `tags` | list[string] | Labels added by later stages, e.g. `uhq` (top-quality subset), `synthetic`, `augmented`. Empty in v1. Filter with `"uhq" in r["tags"]`. |

## Composition

| Source | Hub dataset | Category | Docs | Tokens | Mean length | Segmented | License |
|---|---|---|---:|---:|---:|---:|---|
| `finepdfs-edu` | [HuggingFaceFW/finepdfs-edu](https://huggingface.co/datasets/HuggingFaceFW/finepdfs-edu) | PDFs | 499,065 | 7.34B | 14,704 | 16% | ODC-By 1.0 |
| `fineweb-edu` | [HuggingFaceFW/fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) | Web | 268,881 | 3.79B | 14,095 | 14% | ODC-By 1.0 |
| `gutenberg` | [common-pile/project_gutenberg_filtered](https://huggingface.co/datasets/common-pile/project_gutenberg_filtered) | Books | 192,444 | 3.11B | 16,174 | 92% | open (per doc, Common Pile) |
| `caselaw` | [common-pile/caselaw_access_project_filtered](https://huggingface.co/datasets/common-pile/caselaw_access_project_filtered) | Law | 237,961 | 2.93B | 12,323 | 6% | open (per doc, Common Pile) |
| `usgpo` | [common-pile/usgpo_filtered](https://huggingface.co/datasets/common-pile/usgpo_filtered) | Government | 195,675 | 2.78B | 14,191 | 41% | open (per doc, Common Pile) |
| `pes2o` | [common-pile/peS2o_filtered](https://huggingface.co/datasets/common-pile/peS2o_filtered) | Science | 218,957 | 2.35B | 10,719 | 1% | open (per doc, Common Pile) |
| `youtube` | [common-pile/youtube_filtered](https://huggingface.co/datasets/common-pile/youtube_filtered) | Transcripts | 205,885 | 2.23B | 10,853 | 5% | open (per doc, Common Pile) |
| `finewiki` | [HuggingFaceFW/finewiki](https://huggingface.co/datasets/HuggingFaceFW/finewiki) | Wikipedia | 187,693 | 1.87B | 9,970 | 6% | CC BY-SA 4.0 / GFDL |
| `stack-edu` | [common-pile/stackv2_edu_filtered](https://huggingface.co/datasets/common-pile/stackv2_edu_filtered) | Code | 176,001 | 1.81B | 10,281 | 11% | open (per doc, Common Pile) |
| `doab` | [common-pile/doab_filtered](https://huggingface.co/datasets/common-pile/doab_filtered) | Books | 151,778 | 1.76B | 11,565 | 43% | open (per doc, Common Pile) |
| `pubmed` | [common-pile/pubmed_filtered](https://huggingface.co/datasets/common-pile/pubmed_filtered) | Science | 123,865 | 1.75B | 14,145 | 5% | open (per doc, Common Pile) |
| `ar5iv` | [marin-community/ar5iv-no-problem-markdown](https://huggingface.co/datasets/marin-community/ar5iv-no-problem-markdown) | Science | 126,461 | 1.21B | 9,566 | 1% | arXiv (per paper) |
| `stackexchange` | [common-pile/stackexchange_filtered](https://huggingface.co/datasets/common-pile/stackexchange_filtered) | Q&A | 95,889 | 570.6M | 5,950 | 0% | open (per doc, Common Pile) |
| `rules` | [Andwwy/rules](https://huggingface.co/datasets/Andwwy/rules) | Agent files | 78,808 | 558.7M | 7,089 | 4% | per repository (unverified) |
| `regulations` | [common-pile/regulations_filtered](https://huggingface.co/datasets/common-pile/regulations_filtered) | Government | 42,438 | 297.0M | 6,999 | 12% | open (per doc, Common Pile) |
| `uk-hansard` | [common-pile/uk_hansard_filtered](https://huggingface.co/datasets/common-pile/uk_hansard_filtered) | Transcripts | 10,255 | 159.3M | 15,534 | 87% | open (per doc, Common Pile) |
| `skillmd` | [FayeZC/SkillMD-138K](https://huggingface.co/datasets/FayeZC/SkillMD-138K) | Agent files | 26,832 | 104.1M | 3,880 | 0% | per file (card: CC BY 4.0) |
| `pressbooks` | [common-pile/pressbooks_filtered](https://huggingface.co/datasets/common-pile/pressbooks_filtered) | Textbooks | 23,301 | 99.3M | 4,260 | 1% | open (per doc, Common Pile) |
| `libretexts` | [common-pile/libretexts_filtered](https://huggingface.co/datasets/common-pile/libretexts_filtered) | Textbooks | 17,987 | 65.0M | 3,612 | 1% | open (per doc, Common Pile) |
| `news` | [common-pile/news_filtered](https://huggingface.co/datasets/common-pile/news_filtered) | News | 6,404 | 11.3M | 1,764 | 0% | open (per doc, Common Pile) |
| `oercommons` | [common-pile/oercommons_filtered](https://huggingface.co/datasets/common-pile/oercommons_filtered) | Textbooks | 2,043 | 9.0M | 4,402 | 3% | open (per doc, Common Pile) |
| `peps` | [common-pile/python_enhancement_proposals_filtered](https://huggingface.co/datasets/common-pile/python_enhancement_proposals_filtered) | Tech docs | 597 | 2.6M | 4,342 | 0% | open (per doc, Common Pile) |
| `public-domain-review` | [common-pile/public_domain_review_filtered](https://huggingface.co/datasets/common-pile/public_domain_review_filtered) | Essays | 425 | 1.1M | 2,554 | 0% | open (per doc, Common Pile) |

![Tokens by source](assets/tokens_by_source.png)

![Source mix across lengths](assets/source_mix.png)

<details>
<summary>Per-bucket counts</summary>

| Bucket (tokens) | Docs | Tokens | Largest sources |
|---|---:|---:|---|
| 1,024–2,047 | 181,521 | 267.2M | finepdfs-edu 11%, youtube 7%, pes2o 7% |
| 2,048–3,071 | 175,166 | 440.3M | finepdfs-edu 11%, youtube 7%, pes2o 7% |
| 3,072–4,095 | 168,259 | 596.8M | finepdfs-edu 11%, youtube 7%, pes2o 7% |
| 4,096–5,119 | 163,511 | 748.4M | finepdfs-edu 12%, youtube 7%, pes2o 7% |
| 5,120–6,143 | 155,657 | 871.9M | finepdfs-edu 12%, youtube 8%, pes2o 8% |
| 6,144–7,167 | 150,080 | 994.8M | finepdfs-edu 13%, pes2o 8%, finewiki 8% |
| 7,168–8,191 | 144,972 | 1.11B | finepdfs-edu 13%, pes2o 8%, finewiki 8% |
| 8,192–9,215 | 138,440 | 1.20B | finepdfs-edu 14%, pes2o 9%, finewiki 9% |
| 9,216–10,239 | 132,471 | 1.29B | finepdfs-edu 15%, pes2o 9%, finewiki 9% |
| 10,240–11,263 | 128,087 | 1.37B | finepdfs-edu 15%, pes2o 9%, finewiki 9% |
| 11,264–12,287 | 122,528 | 1.44B | finepdfs-edu 16%, pes2o 10%, caselaw 9% |
| 12,288–13,311 | 115,851 | 1.48B | finepdfs-edu 17%, pes2o 10%, caselaw 10% |
| 13,312–14,335 | 108,186 | 1.49B | finepdfs-edu 18%, pes2o 11%, caselaw 11% |
| 14,336–15,359 | 100,785 | 1.49B | finepdfs-edu 19%, pes2o 12%, caselaw 11% |
| 15,360–16,383 | 94,119 | 1.49B | finepdfs-edu 21%, pes2o 13%, caselaw 11% |
| 16,384–17,407 | 86,953 | 1.47B | finepdfs-edu 22%, pes2o 11%, fineweb-edu 11% |
| 17,408–18,431 | 80,582 | 1.44B | finepdfs-edu 24%, fineweb-edu 11%, caselaw 11% |
| 18,432–19,455 | 74,208 | 1.40B | finepdfs-edu 25%, fineweb-edu 12%, caselaw 10% |
| 19,456–20,479 | 68,718 | 1.37B | finepdfs-edu 26%, fineweb-edu 12%, caselaw 9% |
| 20,480–21,503 | 63,270 | 1.33B | finepdfs-edu 27%, fineweb-edu 13%, gutenberg 9% |
| 21,504–22,527 | 57,848 | 1.27B | finepdfs-edu 27%, fineweb-edu 13%, gutenberg 10% |
| 22,528–23,551 | 52,651 | 1.21B | finepdfs-edu 27%, fineweb-edu 14%, gutenberg 12% |
| 23,552–24,575 | 47,671 | 1.15B | finepdfs-edu 27%, fineweb-edu 14%, gutenberg 12% |
| 24,576–25,599 | 43,812 | 1.10B | finepdfs-edu 27%, fineweb-edu 14%, gutenberg 13% |
| 25,600–26,623 | 40,642 | 1.06B | finepdfs-edu 27%, fineweb-edu 14%, gutenberg 14% |
| 26,624–27,647 | 37,858 | 1.03B | finepdfs-edu 27%, gutenberg 15%, fineweb-edu 14% |
| 27,648–28,671 | 35,840 | 1.01B | finepdfs-edu 27%, gutenberg 16%, fineweb-edu 14% |
| 28,672–29,695 | 33,405 | 974.7M | finepdfs-edu 27%, gutenberg 17%, fineweb-edu 14% |
| 29,696–30,719 | 31,342 | 946.7M | finepdfs-edu 26%, gutenberg 18%, fineweb-edu 14% |
| 30,720–31,743 | 29,652 | 925.9M | finepdfs-edu 27%, gutenberg 18%, fineweb-edu 14% |
| 31,744–32,768 | 25,560 | 823.7M | finepdfs-edu 28%, gutenberg 19%, fineweb-edu 14% |

</details>

## Construction

1. **Sources.** Datasets that are already curated and trusted: FineWeb-Edu, FinePDFs-Edu, FineWiki, ar5iv, the openly
   licensed [Common Pile v0.1](https://huggingface.co/common-pile) subsets (papers, books, textbooks, Q&A, government,
   law, transcripts, educational code), and agent instruction files (`Andwwy/rules`, SkillMD).
2. **Filters.** Source-level quality filters only: FinePDFs-Edu not truncated and without near-duplicates
   (`minhash_cluster_size == 1`); Stack-Edu code with edu score ≥ 3; agent files mostly Latin script and with no
   credential patterns.
3. **Length.** Every document is tokenized with the MiniCPM5-2B tokenizer. Documents of 1,024–32,768 tokens are kept
   whole. Longer documents (mostly books, theses and long reports) are cut into at most 6 consecutive segments at
   paragraph breaks. Each segment is sized for a random length bucket that still needs documents.
4. **Balance.** Each source collects up to a fixed number of documents per bucket (6,000; FinePDFs-Edu 12,000), so no
   single source can dominate a bucket. The merge removes exact duplicates and keeps every remaining document; buckets
   are not truncated, so balancing by length happens at load time.
5. **Determinism.** Sources, files and rows are chosen with fixed seeds. Building again from the same Hub revisions
   gives the same IDs and nearly the same selection.


## Cleaning (v1.1)

Conservative, rule-based, chosen by reading flagged documents from a 3% stratified sample; rules with real false positives were narrowed to the sources where they only caught junk.

| Step | Documents |
|---|---:|
| dropped: `repeated` | 2,864 |
| dropped: `table_dump` | 2,843 |
| dropped: `symbol_soup` | 2,254 |
| dropped: `non_english` | 1,187 |
| dropped: `nav_menu` | 82 |
| dropped: `out_of_range_after_fix` | 35 |
| repaired: `nul` | 13,553 |
| repaired: `mojibake` | 2,236 |
| moved to another bucket after repair | 601 |

`non_english`: mostly non-Latin text; `symbol_soup`: under 60% letters, digits and spaces (prose sources); `repeated`: over half the text in repeated lines (PDFs and US government sources); `table_dump`: number tables of one or two words per line; `nav_menu`: scraped site navigation. `nul`: NUL bytes removed; `mojibake`: wrong-encoding text such as `’` repaired with ftfy. Repaired documents keep their `id` and list the repairs in `metadata.cleaned`. Earlier versions stay available in the repository history.

## Limitations

- **Long buckets are less diverse.** Natural documents over ~16K tokens are rare outside PDFs, papers and books, so
  those categories dominate the long end. Later stages add synthetic long documents.
- **Not decontaminated** against any benchmark. Check overlap before using docs1 near an evaluation set.
- **Novelty varies.** Wikipedia and famous texts are likely known to the base model; papers, PDFs and agent files much
  less so.
- **Mixed licenses.** The repository is marked CC BY-NC-ND 4.0, but each document also keeps its source license
  (see `metadata.license` where present; e.g. Wikipedia is CC BY-SA). Check the source license before reuse.
- **English only**, by source selection (no language filter on Common Pile subsets beyond their own).

## Roadmap

- **Stage 2, original documents:** newly scraped material (recent docs, repositories, papers) and model-written
  documents aimed at specific length buckets (`source_type = "original"`).
- **Stage 3, augmented documents:** model-made variants of docs1 documents, from small factual edits to style changes.
  Each records `metadata.parent_id`.

## Reproduce

```bash
# Stage 1: one CPU job per source group (8 in parallel)
uv run gpu --provider aws --region us-east-1 sagemaker submit datasets/docs1/collect.sh --instance ml.c6i.32xlarge --name aq-docs1-<group>
# Stage 2: merge, card, publish
uv run gpu --provider aws --region us-east-1 sagemaker submit datasets/docs1/merge.sh --instance ml.r6i.16xlarge --name aq-docs1-merge
```

Code: `datasets/docs1/` in the AlphaQualia repository.