EXOROBOURII commited on
Commit
111a9d3
·
verified ·
1 Parent(s): ae00bf9

Update README.md

Browse files

Repo is under construction.

Files changed (1) hide show
  1. README.md +249 -37
README.md CHANGED
@@ -8,67 +8,279 @@ language:
8
  - en
9
  size_categories:
10
  - 100K<n<1M
11
- pretty_name: 'Stanza-2: Geometry-Aware WikiText'
 
 
 
 
 
 
 
12
  ---
 
13
  # Dataset Card for Stanza-2
14
 
15
  ## Dataset Description
16
- Stanza-2 is a structurally pristine, mathematically verified NLP dataset designed specifically for multi-task language modeling, custom tokenizer training, and mechanistic interpretability research.
17
 
18
- It is a rigorously modernized and annotated derivative of the `wikitext-2-raw-v1` corpus. By utilizing the Stanford NLP `Stanza` pipeline, every word in the corpus has been explicitly mapped to its grammatical, syntactic, and semantic function. Crucially, Stanza-2 preserves document geometry, explicitly labeling Markdown headers to support structure-aware neural architectures.
 
 
19
 
20
  - **Curated by:** Jonathan R. Belanger (Exorobourii LLC)
21
  - **Language:** English (`en`)
22
  - **License:** CC-BY-SA-4.0
23
- - **Total Rows:** 101,455 sentences (~2.46 Million Tokens)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ## Dataset Structure
26
- Stanza-2 abandons flat-text formatting in favor of **Parallel Arrays**. Each row in the dataset represents a single sentence. The linguistic features of that sentence are stored in perfectly aligned, equal-length arrays, guaranteeing 1:1 token-to-tag mapping.
 
27
 
28
  ### Schema
29
- * `chunk_id` (int64): The positional ID of the chunk within the document stream.
30
- * `sentence_id` (int64): The positional ID of the sentence within its chunk.
31
- * `raw_text` (string): The cleaned, normalized raw string of the sentence.
32
- * `is_header` (bool): `True` if the sentence is a structural document header.
33
- * `section_level` (int64): The Markdown depth of the header (1-6). `0` if not a header.
34
- * `tokens` (list[str]): The tokenized string sequence.
35
- * `lemmas` (list[str]): The base morphological root of each token.
36
- * `upos` (list[str]): Universal Part-of-Speech tags.
37
- * `xpos` (list[str]): Treebank-specific Part-of-Speech tags.
38
- * `head` (list[int64]): The 1-based index of the syntactic parent (Dependency Graph).
39
- * `deprel` (list[str]): The syntactic dependency relation to the head token.
40
- * `ner` (list[str]): Named Entity Recognition tags in explicit BIOES format.
 
 
 
 
 
 
 
41
 
42
  ## Methodology & Provenance
43
 
44
- ### 1. Cryptographic Ingestion
 
45
  To prevent silent upstream updates from compromising downstream reproducibility, this dataset was built from a cryptographically verified snapshot of the `ggml-org/ci` raw mirror.
46
- * **Source Archive:** `wikitext-2-raw-v1.zip`
47
- * **SHA-256 Checksum:** `ef7edb566e3e2b2d31b29c1fdb0c89a4cc683597484c3dc2517919c615435a11`
48
 
49
- ### 2. The Normalization Ledger
50
- The legacy WikiText corpus contains archaic spacing and tokenization artifacts. Prior to semantic enrichment, the text underwent strict, idempotent modernization passes to ensure sub-word tokenizers are not biased by historical formatting:
51
- * **Hyphenation:** Legacy `@-@` artifacts were strictly mapped to standard hyphens (`-`).
52
- * **Punctuation Alignment:** Floating terminal punctuation (e.g., `word , word`) and floating brackets were realigned to their preceding/succeeding semantic tokens. *Note: Vectorized backreferences were routed through standard Python CPU processing to bypass known `libcudf` regex injection vulnerabilities.*
53
- * **Structural Preservation:** Legacy `= Header =` formats were mapped to standard Markdown (`# Header`) using strict descending-order regex (H6 down to H1) to prevent partial matching and preserve true document hierarchy.
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- ### 3. Graph Integrity Protocol
56
- Following the Stanza `depparse` enrichment, the resulting Parquet files were subjected to a microscopic mathematical audit. The Stanza-2 dataset guarantees 100% structural integrity:
57
- 1. **Dimensional Symmetry:** Every parallel array (`tokens`, `upos`, `ner`, etc.) within a row is guaranteed to be the exact same length.
58
- 2. **Root Singularity:** Every sentence possesses exactly one dependency root (`head == 0`).
59
- 3. **Graph Bounds:** No dependency head points to an index outside the bounds of the sentence.
60
- *Note: During the final Phase 4b integrity audit, 8 sentences out of ~101,463 across the training split violated graph bounds or root singularity due to extreme source fragmentation. These 8 rows were surgically dropped to preserve absolute dataset-wide mathematical validity.*
61
 
62
- ### 4. Structural Grammar Baseline
63
- Analysis of the `wiki.train` split reveals exactly 451 unique `(UPOS, DepRel)` structural combinations across ~2.46 million tokens, demonstrating a highly rigid grammatical scaffold suitable for entropy reduction in custom tokenizer design.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  ## Usage
66
- Because the dataset uses PyArrow-backed lists for parallel arrays, loading it into standard ML pipelines is highly efficient:
67
 
68
  ```python
69
  import pandas as pd
 
 
70
  df = pd.read_parquet("hf://datasets/EXOROBOURII/Stanza-Wikitext-2/wiki.train.enriched.parquet")
71
 
72
- # Example: Accessing perfectly aligned tokens and their dependency relations
73
- first_sentence_tokens = df.iloc[0]['tokens']
74
- first_sentence_relations = df.iloc[0]['deprel']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  - en
9
  size_categories:
10
  - 100K<n<1M
11
+ pretty_name: 'Stanza-2: Geometry-Aware WikiText'
12
+ tags:
13
+ - dependency-parsing
14
+ - universal-dependencies
15
+ - nlp-dataset
16
+ - structural-linguistics
17
+ - named-entity-recognition
18
+ - wikipedia
19
  ---
20
+
21
  # Dataset Card for Stanza-2
22
 
23
  ## Dataset Description
 
24
 
25
+ Stanza-2 is a structurally pristine, mathematically verified NLP dataset designed for multi-task language modeling, custom tokenizer training, structural NLP research, and mechanistic interpretability work.
26
+
27
+ It is a rigorously modernized and annotated derivative of the `wikitext-2-raw-v1` corpus. Using the Stanford NLP `Stanza` neural pipeline, every token in the corpus has been explicitly mapped to its grammatical, syntactic, and semantic function across seven aligned annotation layers. Stanza-2 preserves document geometry, explicitly labeling Markdown headers to support structure-aware neural architectures.
28
 
29
  - **Curated by:** Jonathan R. Belanger (Exorobourii LLC)
30
  - **Language:** English (`en`)
31
  - **License:** CC-BY-SA-4.0
32
+ - **DOI:** Locked at publication
33
+ - **Total Sentences:** 101,455 (across all splits)
34
+ - **Total Tokens:** 2,469,912
35
+
36
+ ---
37
+
38
+ ## Corpus Statistics
39
+
40
+ | Split | Sentences | Tokens |
41
+ |-------|-----------|--------|
42
+ | Train | 82,760 | 2,021,438 |
43
+ | Validation | 8,622 | 210,732 |
44
+ | Test | 10,073 | 237,742 |
45
+ | **Total** | **101,455** | **2,469,912** |
46
+
47
+ Rows discarded by degradation filter: **8** (out of ~101,463 pre-filter)
48
+
49
+ ---
50
+
51
+ ## Structural Characterization
52
+
53
+ Unlike standard text corpora, Stanza-2 ships with a full quantitative geometric characterization derived from its dependency structure. These figures are provided to assist researchers in assessing corpus suitability before use.
54
+
55
+ ### Dependency Degree Distribution
56
+
57
+ Dependency degree (number of dependents per token) follows a power-law distribution with exponent **α = −1.06**. The corpus is heavily left-concentrated — the majority of tokens are leaves.
58
+
59
+ | Percentile | Degree |
60
+ |-----------|--------|
61
+ | 50th (median) | 0 |
62
+ | 90th | 3 |
63
+ | 99th | 6 |
64
+ | 99.9th | 9 |
65
+ | Maximum | 43 |
66
+
67
+ - Degree entropy: **1.839 bits**
68
+ - Effective degree vocabulary: degree 0–11 (values above 12 are sparse artifacts of list coordination)
69
+
70
+ ### Token Depth Distribution
71
+
72
+ Token depth (distance from dependency root, measured upward) characterizes positional distribution within the tree.
73
+
74
+ | Metric | Value |
75
+ |--------|-------|
76
+ | Range | 0 – 25 |
77
+ | Mean | 2.745 |
78
+ | Std | 1.674 |
79
+ | Entropy | 2.679 bits |
80
+
81
+ Mean subtree height (measured downward from each node): **5.45 nodes**. Maximum subtree height: **26 nodes**. Root center of mass: **0.24**.
82
+
83
+ ### Structural Grammar Matrix
84
+
85
+ The cross-product of UPOS tags and DepRel labels yields **451 unique UPOS×DepRel combinations** observed across the corpus. This matrix constitutes a compact geometric fingerprint of the corpus's syntactic behavior and is available as `structural_grammar_matrix.csv` in the associated reports.
86
+
87
+ ### Geometric Motif Analysis
88
+
89
+ A dependency motif is defined as a parent node (UPOS×DepRel) paired with a sorted tuple of its children's (UPOS×DepRel) labels. The train split contains **106,057 unique motifs** following a power-law frequency distribution.
90
+
91
+ | Coverage | Motifs Required |
92
+ |----------|----------------|
93
+ | 50% | 343 |
94
+ | 80% | ~3,500 |
95
+ | 90% | ~12,000 |
96
+ | 95% | ~30,000 |
97
+ | 100% | 106,057 |
98
+
99
+ The top 343 motifs account for half of all motif occurrences — a Zipfian concentration consistent with the structural redundancy hypothesis underlying geometry-aware tokenizer design.
100
+
101
+ ### Structural Rigidity by UPOS
102
+
103
+ Dependency degree varies substantially by part-of-speech, reflecting syntactic valency differences. VERB is the highest-degree head class; functional categories cluster near zero.
104
+
105
+ | UPOS | Mean Degree | Max Degree | Entropy (bits) |
106
+ |------|-------------|------------|----------------|
107
+ | VERB | 3.54 | 15 | 2.88 |
108
+ | NOUN | 2.22 | 36 | 2.61 |
109
+ | PROPN | 1.32 | 43 | 2.27 |
110
+ | ADJ | 0.56 | 17 | 1.32 |
111
+ | ADV | 0.25 | 9 | 0.89 |
112
+ | AUX | 0.02 | 8 | 0.11 |
113
+ | DET | 0.02 | 10 | 0.11 |
114
+ | PUNCT | 0.006 | 11 | 0.03 |
115
+ | PART | 0.005 | 6 | 0.03 |
116
+
117
+ ### Structural Information Content
118
+
119
+ Normalized mutual information between structural measurements and linguistic labels:
120
+
121
+ | Pair | NMI |
122
+ |------|-----|
123
+ | Degree × UPOS | 0.223 |
124
+ | Degree × DepRel | 0.294 |
125
+ | Depth × UPOS | 0.054 |
126
+ | Depth × DepRel | 0.118 |
127
+
128
+ Degree carries substantially more linguistic signal than depth. Neither measurement is redundant with linguistic category — they capture geometrically distinct aspects of syntactic structure.
129
+
130
+ ### Per-Sentence Structural Complexity
131
+
132
+ Per-sentence degree entropy has mean **1.555 bits** (std 0.275, max 1.954 bits). The tight distribution indicates consistent structural complexity across sentences, with limited register variance attributable to the Wikipedia source.
133
+
134
+ ---
135
 
136
  ## Dataset Structure
137
+
138
+ Stanza-2 uses **Parallel Arrays**. Each row represents a single sentence. All linguistic features are stored in co-indexed, equal-length arrays guaranteeing 1:1 token-to-annotation alignment.
139
 
140
  ### Schema
141
+
142
+ | Column | Type | Description |
143
+ |--------|------|-------------|
144
+ | `chunk_id` | int64 | Positional ID of the text block within the document stream |
145
+ | `sentence_id` | int64 | Positional ID of the sentence within its chunk |
146
+ | `raw_text` | string | Cleaned, normalized sentence text |
147
+ | `is_header` | bool | `True` if the sentence is a structural document header |
148
+ | `section_level` | int64 | Markdown header depth (1–6); `0` if not a header |
149
+ | `tokens` | list[str] | Surface word forms |
150
+ | `lemmas` | list[str] | Morphological base forms |
151
+ | `upos` | list[str] | Universal POS tags (17-class UD tagset) |
152
+ | `xpos` | list[str] | Penn Treebank POS tags |
153
+ | `head` | list[int64] | 1-indexed syntactic head positions (0 = root anchor) |
154
+ | `deprel` | list[str] | Universal Dependencies relation labels |
155
+ | `ner` | list[str] | Named entity tags in BIOES format |
156
+
157
+ All array columns are co-indexed: `column[i]` refers to the same token across all columns for a given row.
158
+
159
+ ---
160
 
161
  ## Methodology & Provenance
162
 
163
+ ### Phase 1: Cryptographic Ingestion
164
+
165
  To prevent silent upstream updates from compromising downstream reproducibility, this dataset was built from a cryptographically verified snapshot of the `ggml-org/ci` raw mirror.
 
 
166
 
167
+ - **Source Archive:** `wikitext-2-raw-v1.zip`
168
+ - **SHA-256 Checksum:** `ef7edb566e3e2b2d31b29c1fdb0c89a4cc683597484c3dc2517919c615435a11`
169
+
170
+ ### Phase 2: Degradation Filtering
171
+
172
+ WikiText-2's unknown token substitution (`<unk>`) is non-uniform. A penalized degradation score is computed per text block:
173
+
174
+ ```
175
+ D*(P) = (|unk| / N) · log₂(1 + √N)
176
+ ```
177
+
178
+ The logarithmic penalty prevents discrimination against longer passages with isolated `<unk>` tokens. The discard threshold is set at μ + 2σ over the distribution of affected blocks. **8 rows were discarded** under this criterion.
179
+
180
+ ### Phase 3: GPU-Accelerated Normalization
181
+
182
+ Text normalization was performed using NVIDIA RAPIDS cuDF on an L4 GPU. Four operations applied in sequence:
183
 
184
+ 1. **Whitespace normalization:** leading/trailing whitespace stripped
185
+ 2. **Hyphen modernization:** legacy `@-@` artifacts collapsed to standard hyphens
186
+ 3. **Punctuation normalization:** floating punctuation corrected via CPU bypass using Python `re` with backreferences *(cuDF vectorized backreferences routed through standard Python to bypass known libcudf regex injection vulnerabilities)*
187
+ 4. **Header normalization:** `= Title =` through `====== Title ======` converted to Markdown H1–H6 in strict descending order to preserve document hierarchy
 
 
188
 
189
+ ### Phase 4: Stanza NLP Enrichment
190
+
191
+ Stanza 1.x initialized with `tokenize, pos, lemma, depparse, ner` on GPU. Output serialized to Parquet with ZSTD compression (level 3).
192
+
193
+ Following enrichment, all Parquet files were subjected to a microscopic integrity audit guaranteeing:
194
+
195
+ 1. **Dimensional symmetry:** all parallel arrays within a row are equal length
196
+ 2. **Root singularity:** every sentence has exactly one dependency root (`head == 0`)
197
+ 3. **Graph bounds:** no head index points outside the sentence boundary
198
+
199
+ The Stanza-2 dataset is **100% structurally valid** across all splits.
200
+
201
+ ### Phase 5: Structural Metadata Injection
202
+
203
+ `is_header` and `section_level` columns injected via vectorized Markdown header detection. Enables structure-aware models to condition on document position without reprocessing raw text.
204
+
205
+ ---
206
 
207
  ## Usage
 
208
 
209
  ```python
210
  import pandas as pd
211
+
212
+ # Load a split
213
  df = pd.read_parquet("hf://datasets/EXOROBOURII/Stanza-Wikitext-2/wiki.train.enriched.parquet")
214
 
215
+ # Aligned token access
216
+ sentence = df.iloc[0]
217
+ for token, upos, deprel, head in zip(
218
+ sentence['tokens'],
219
+ sentence['upos'],
220
+ sentence['deprel'],
221
+ sentence['head']
222
+ ):
223
+ print(f"{token:<20} {upos:<8} {deprel:<16} head={head}")
224
+
225
+ # Filter to content sentences only (exclude headers)
226
+ content = df[~df['is_header']].reset_index(drop=True)
227
+
228
+ # Filter to a specific section level
229
+ h2_headers = df[df['section_level'] == 2]
230
+
231
+ # Reconstruct dependency tree for a sentence
232
+ from collections import defaultdict
233
+
234
+ def get_children(head_array):
235
+ children = defaultdict(list)
236
+ for i, h in enumerate(head_array):
237
+ if h > 0:
238
+ children[h - 1].append(i) # convert to 0-indexed
239
+ return children
240
+
241
+ row = df.iloc[10]
242
+ children = get_children(row['head'])
243
+ root_idx = list(row['head']).index(0)
244
+ print(f"Root token: {row['tokens'][root_idx]} ({row['upos'][root_idx]})")
245
+ print(f"Root dependents: {[row['tokens'][c] for c in children[root_idx]]}")
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Reports and Analysis Artifacts
251
+
252
+ The following analytical reports are available in the dataset repository:
253
+
254
+ | File | Description |
255
+ |------|-------------|
256
+ | `structural_grammar_matrix.csv` | 451 UPOS×DepRel combinations with frequencies |
257
+ | `geometric_motifs_wiki.train.enriched.csv` | 106,057 unique dependency motifs |
258
+ | `entity_distribution.csv` | Named entity frequencies and types |
259
+ | `entity_cooccurrence.csv` | Sentence-level entity co-occurrence pairs |
260
+ | `motif_analytics_summary.txt` | Power-law analysis and valency statistics |
261
+ | `structural_rigidity_full.csv` | Per-UPOS weighted valency statistics |
262
+ | `degree_distribution.csv` | Full token degree frequency table |
263
+ | `depth_distribution.csv` | Full token depth frequency table |
264
+ | `mi_summary.csv` | NMI values for degree/depth × UPOS/DepRel |
265
+ | `sentence_structural_stats.csv` | Per-sentence degree and depth statistics |
266
+
267
+ ---
268
+
269
+ ## Citation
270
+
271
+ ```bibtex
272
+ @dataset{belanger2025stanza2,
273
+ author = {Belanger, Jonathan R.},
274
+ title = {Stanza-2: A Structurally Enriched Modernization of WikiText-2},
275
+ year = {2025},
276
+ publisher = {HuggingFace},
277
+ url = {https://huggingface.co/datasets/EXOROBOURII/Stanza-Wikitext-2},
278
+ doi = {[10.57967/hf/8060]}
279
+ }
280
+ ```
281
+
282
+ ---
283
+
284
+ ## License
285
+
286
+ CC-BY-SA-4.0. Derivative of WikiText-2 (CC-BY-SA-4.0, Merity et al. 2016).