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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#!/usr/bin/env python3
"""Generate Dynaword documentation: per-source datasheets + README + CHANGELOG + LICENSE.



Reads sources.py + data/<source>/<source>.stats.json (written by build_dynaword.py).

Implements the "Documented" principle (datasheets, Gebru et al. 2021) and the

aggregate README table (paper 2508.02271).

"""
from __future__ import annotations
import json, sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))
from sources import SOURCES, EXCLUDED, ADDED

ROOT = Path(__file__).resolve().parent.parent
VERSION = "0.2.4"
RELEASE_DATE = "2026-08-07"
CONTACT = "k.wikiel@gmail.com"  # notice-and-takedown / data-removal requests

# Dupochron: documented good-faith provenance + no-warranty + takedown + PII.
DISCLAIMER = f"""## Personal & sensitive data

This corpus contains **only** text that its upstream sources already published

under open licenses or as official public-domain record. It therefore includes

names and statements of **public figures acting in a public capacity** — e.g.

parliamentary speakers (PPC), authorities named in legal acts (EUR-Lex), and

people described in encyclopedic articles (Wikipedia/Wikisource). No private,

non-public personal data was collected or added. If you are a data subject and

want content concerning you removed, contact **{CONTACT}** — it will be dropped

from the next version (see retroactive-removal policy below).



## Disclaimer & legal

- **Provenance in good faith.** Per-source licenses are reproduced *as documented

  by the upstream sources and by SpeakLeash* (the intermediate aggregator), to the

  best of our knowledge. We make no independent legal warranty about the copyright

  status of any individual document.

- **No ownership claim.** This release is a *curated, license-reviewed, documented

  aggregation*. We claim no ownership of the underlying texts; rights remain with

  the original authors/rightsholders under their respective licenses.

- **Provided "as is"**, without warranty of any kind, express or implied. This is

  not legal advice.

- **Your compliance is yours.** Downstream users must satisfy each upstream

  license themselves — in particular **CC-BY-SA-4.0 attribution and share-alike**

  for derivatives of this dataset, and attribution to the upstream sources and to

  SpeakLeash.

- **Notice-and-takedown.** Any source or rightsholder raising a substantiated

  objection can have material removed: contact **{CONTACT}**; it is dropped from

  the next version and recorded in the CHANGELOG. Removal is retroactive

  going-forward (prior immutable snapshots/commits may persist).

"""


def load_stats(name):
    f = ROOT / "data" / name / f"{name}.stats.json"
    return json.loads(f.read_text()) if f.exists() else None


def datasheet(name, cfg, st):
    license_rows = ""
    licenses = st.get("licenses") or {}
    if licenses:
        top = sorted(licenses.items(), key=lambda item: -item[1])[:20]
        license_rows = "\n\n## Per-document license metadata\n| license | documents |\n|---|---:|\n"
        license_rows += "\n".join(f"| `{k or 'UNKNOWN'}` | {v:,} |" for k, v in top)
    author_note = ""
    if "authors_with_value" in st:
        author_note = (
            f"\n\nAuthor metadata present for **{st.get('authors_with_value', 0):,}** "
            "documents. Empty values mean the upstream record did not expose a "
            "machine-readable author field."
        )
    legal_note = cfg.get("legal_note", "")
    if legal_note:
        legal_note = f"\n\n## Legal scope note\n{legal_note}"
    source_note = ""
    if st.get("stats_recomputed_from_parquet"):
        source_note = "\n\nStatistics were recomputed directly from the released parquet file."
    return f"""# {name}



{cfg['pretty']}



## Dataset description

- **Source (upstream):** {cfg['upstream']}

- **Domain:** {cfg['domain']}

- **Language:** Polish (pl)

- **License:** `{cfg['license']}`

- **Created (range):** {cfg['created']}

- **Added:** {ADDED}



## Licensing — traceable basis

{cfg['traceable']}



## Provenance

{cfg.get('provenance', f"Pulled from SpeakLeash's public redistribution "

 f"(`speakleash-ds-pub`, key `{cfg.get('speakleash_key')}`) of the upstream source "

 f"above. SpeakLeash credited as intermediate aggregator; upstream "

 f"license/attribution preserved.")}



## Statistics

| documents | characters | tokens (tiktoken proxy) |

|---:|---:|---:|

| {st['kept']:,} | {st['chars']:,} | {st['tokens']:,} |

{license_rows}{author_note}{legal_note}{source_note}



## Filters applied (build_dynaword.py)

Minimal, per Dynaword guidelines (heavy filtering left to downstream use):

- drop documents < 200 chars: **{st.get('drop_short', 0):,}**

- drop non-Polish (diacritic ratio): **{st.get('drop_lang', 0):,}**

- exact cross-source dedup (sha1): **{st.get('drop_dup', 0):,}**

- OCR alpha-ratio < 0.70 (OCR sources only): **{st.get('drop_ocr', 0):,}**

- read {st.get('read', st['kept']):,} → kept {st['kept']:,}



Token counts are a fast tiktoken (cl100k) proxy (~1% off Llama-3); the canonical

Llama-3 count is computed at release.

"""


def main():
    rows, tot_doc, tot_tok, tot_chr = [], 0, 0, 0
    for name, cfg in SOURCES.items():
        st = load_stats(name)
        if not st:
            print(f"  ! no stats for {name}"); continue
        # Sources with a hand-authored datasheet (rich provenance, per-source add
        # date) opt out of template regeneration to avoid clobbering it.
        if not cfg.get("custom_datasheet"):
            (ROOT / "data" / name / f"{name}.md").write_text(datasheet(name, cfg, st))
        rows.append((name, cfg, st))
        tot_doc += st["kept"]; tot_tok += st["tokens"]; tot_chr += st["chars"]
    rows.sort(key=lambda r: -r[2]["tokens"])

    tbl = "\n".join(
        f"| [{n}](data/{n}/{n}.md) | {c['pretty']} | `{c['license']}` | "
        f"{s['kept']:,} | {s['tokens']/1e6:,.1f}M |"
        for n, c, s in rows)
    excl = "\n".join(f"| `{k}` | {v} |" for k, v in EXCLUDED.items())
    phrase_frequency = ""
    phrase_path = ROOT / "artifacts" / "pattern_frequency_hf_snippet.md"
    if phrase_path.exists():
        snippet = phrase_path.read_text().replace(
            "## Phrase frequency in corpus (token-normalized)\n\n", ""
        )
        phrase_frequency = (
            "\n## Results\n\n"
            "### Corpus phrase frequency (normalized by tokens)\n\n"
            "Raw counts and token-normalized shares are regenerated from the "
            "current parquet files with `src/pattern_frequency_report.py`.\n\n"
            f"{snippet}"
        )

    readme = f"""---

license: cc-by-sa-4.0

language:

- pl

pretty_name: Polish DynaWord

task_categories:

- text-generation

size_categories:

- 1M<n<10M

tags:

- polish

- pretraining

- dynaword

---



# Polish DynaWord



A continuously developed, **openly-licensed**, human-text Polish corpus — a Polish

edition in the [Dynaword](https://huggingface.co/datasets/danish-foundation-models/danish-dynaword)

family (Enevoldsen et al., [arXiv:2508.02271](https://arxiv.org/abs/2508.02271)).



> **v{VERSION} stable** · {tot_doc:,} documents · **{tot_tok/1e9:.2f}B tokens**

> (tiktoken proxy; canonical Llama-3 count at release) · {len(rows)} sources

> Updated: **{RELEASE_DATE}**



> **v0.3-dev experimental track** · quality/diversity workflow, source-gate

> validation and candidate-data audits. This is development work, not a released

> corpus version, and it does not replace the v{VERSION} stable parquets.



> **Europeana validation artifact (2026-07-10)** · a separate reproducible

> 810-document direct-ingestion sample stored under the legacy path

> `previews/v0.3.1/europeana.parquet`. It is not a full dataset release.



## Releases



### Stable releases



| version | status | documents | tokens | notes |

|---|---|---:|---:|---|

| `v0.2.4` | stable release | {tot_doc:,} | {tot_tok/1e9:.2f}B | Expanded `european_hplt_v3_pl` to WDS bins 10-5 (+1.49M docs / 2.04B tok); phone PII-scrub hardening (independent dual-lens) + cross-source dedup (zero-overlap). |

| `v0.2.3` | previous stable | 2,710,974 | 6.88B | Adds community-contributed `european_hplt_v3_pl`, `global_voices` and `nkjp1m`. |

| `v0.2.2` | previous stable | 2,579,963 | 6.36B | Added community-contributed `govpl`: 88,190 docs / 80.7M tokens. |

| `v0.2.1` | previous stable | 2,491,773 | 6.28B | 12-source corpus with `license` and `author` metadata columns; added `1000_novels`. |

| `v0.2.0` | previous stable | 2,490,773 | 6.22B | Provenance-first corpus from 11 open/official sources. |



![Stable dataset size by version](artifacts/dataset_size_by_version.png)



### Development and validation artifacts



| name | type | scope | notes |

|---|---|---|---|

| `v0.3-dev` | experimental development track | workflow and candidate audits | Quality remix, legal-source caps, source QA, deduplication and direct-upstream ingestion. Not a corpus release. |

| `Europeana validation artifact 2026-07-10` | reproducible sample | 810 documents / 140,042 tokens | Stored at the legacy path `previews/v0.3.1/europeana.parquet`; preserves per-record rights and creator metadata. Not a corpus release. |



### Version details



#### v0.2.4 — current stable



Expanded `european_hplt_v3_pl` from WDS bins 10+9 to **WDS bins 10-5** (added

quality bins 8/7/6/5 and further WDS-9 shards): **+1,493,384 documents /

2,043,141,874 cl100k-proxy tokens**, 100% CC0-1.0. Includes a phone PII-scrub

hardening pass (v12b) verified by two independent lenses (a systematic

recall-gap masked by pipeline self-report was caught pre-release), and

cross-source deduplication against the existing WDS-10+9 shards (exact-dup 0,

near-dup overlap 0.0000%, byte-verified) — resolving the "downstream near-dedup

remains" caveat from the original release.



#### v0.2.3 — previous stable



Community expansion release. Adds `european_hplt_v3_pl` from

[PR #5](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/5)

and `global_voices` from

[PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7),

plus `nkjp1m` from

[PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8).

The complete 16-source release contains **2,710,974 documents /

6,881,277,362 cl100k-proxy tokens**, summed from the released per-source parquet

statistics.



#### v0.2.2 — previous stable



Added `govpl` from

[PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9):

88,190 Polish government press releases collected directly from 133 gov.pl

ministry and agency subsites.



#### v0.2.1 — previous stable



Introduced the canonical eight-column release schema:

`id, text, source, added, created, token_count, license, author`. Added

`1000_novels` from

[PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1)

and recomputed all release statistics from parquet files.



#### v0.2.0 — initial stable corpus



The provenance-first baseline: 11 reviewed open or official sources,

2,490,773 documents and 6.22B proxy tokens.



#### v0.3-dev — experimental quality workflow



Candidate-only work on a better-balanced training mixture: legal-source caps,

temperature sampling, source QA, deduplication and direct-upstream ingestion.

It is not a replacement for the stable corpus.



#### Europeana validation artifact — 2026-07-10



A separate reproducible 810-document Europeana sample preserving per-record

rights and creator metadata. It does not change stable-release totals.

`v0.3.1-preview` remains only as the legacy storage-path label.



## What this dataset contributes

The raw texts come from existing open corpora (redistributed via SpeakLeash and,

where applicable, fetched from upstream). **The value added here is the curation,

not the bytes**, following the Dynaword methodology:



1. **License review per source** — each source vetted for an *openly-licensed,

   traceable* legal basis (documented in its datasheet); sources that fail the

   review are **excluded with a stated reason** (see table below), not silently

   kept. This is the core editorial work.

2. **Filtering & normalization** — minimal, reproducible gates (short-doc,

   non-Polish, exact cross-source dedup, OCR garble) applied uniformly to one

   clean schema: `id, text, source, added, created, token_count, license, author`.

3. **Documentation** — a datasheet per source (Gebru et al. 2021) + this card,

   so provenance and licensing are auditable rather than assumed.

4. **Reproducibility & versioning** — `src/` rebuilds the corpus from sources;

   new sources and removals are tracked in the CHANGELOG.



Credit for the underlying texts belongs to the upstream sources and to SpeakLeash

as the redistributing aggregator; this release does not claim ownership of them

(see Disclaimer).



## Contributors



| contributor | contribution | release / PR |

|---|---|---|

| [Kacper Wikieł](https://huggingface.co/kacperwikiel) | Project maintainer; corpus curation, source and license review, release engineering, documentation, validation and reproducible build workflow. | all releases |

| [Bart Kobyliński](https://huggingface.co/bartoszkobylinski1) | Added `1000_novels`; expanded Biblioteka Nauki and Europeana ingestion with per-document license and author metadata. | `v0.2.1`, [PR #1](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/1) |

| [Paweł Puzio](https://huggingface.co/ppuzio) | Built `govpl`: subsite discovery, direct ingestion pipeline, dataset artifact, contract tests and documentation. | `v0.2.2`, [PR #9](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/9) |

| [Arkadiusz Słota](https://huggingface.co/Maggio33) | Built & expanded `european_hplt_v3_pl`: HPLT v3 WDS 10+9 (PR #5) then WDS 10-5 expansion (+1,493,384 docs / 2.04B tok), modular cleaning pipeline, phone-recall PII-scrub (v12b, independent dual-lens), cross-source dedup-vs-base (zero-overlap), validation and documentation. | `v0.2.3` (PR #5), `v0.2.4` |

| [Dawid Majewski](https://huggingface.co/dawidmajewski) | Added the reviewed Global Voices Polish corpus with per-document author attribution and documentation. | `v0.2.3`, [PR #7](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/7) |

| [1am](https://huggingface.co/1am) | Added `nkjp1m`: the manually annotated 1-million-word NKJP subcorpus, direct fetch/build pipeline, source documentation and release artifact. | `v0.2.3`, [PR #8](https://huggingface.co/datasets/SlayerLab/polish-dynaword/discussions/8) |



Contributions are credited when they add a verifiable dataset artifact, pipeline,

validation, documentation or release work. A merged discussion with no resulting

files is not listed as a data contribution.



## Guiding principles

1. **Open & traceable licensing** — every source is *openly licensed* with a documented

   legal basis (see each datasheet's "traceable basis"), not a vague "public domain".

2. **Reproducibility** — `src/build_dynaword.py` rebuilds the corpus from sources.

3. **Documented** — a datasheet per source under `data/<source>/`.

4. **Extensibility** — versioned; new sources via PR.



## Sources

| source | description | license | documents | tokens |

|---|---|---|---:|---:|

{tbl}

| **total** | | | **{tot_doc:,}** | **{tot_tok/1e6:,.1f}M** |



## Method

Only **human-authored** text — no synthetic, machine-translated, or auto-transcribed

data. Gates are intentionally minimal (drop short docs, non-Polish, exact duplicates,

OCR garble); heavy quality filtering and mix-weighting are left to downstream training.

Evaluation-set decontamination is applied/marked separately. Schema:

`id, text, source, added, created, token_count, license, author`. The `license`

and `author` columns are per-document metadata when upstream exposes them; older

sources use the source-level license and an empty author field.



## v0.3 quality roadmap and current status



The v0.2.x raw corpus is intentionally provenance-first, but its token mix is too

heavy in legal/parliamentary language for natural general pretraining. The v0.3

workflow therefore separates **source inclusion** from **training mix**:



- cap `eurlex + parliamentary + dziennik_ustaw` to roughly **10-20%** of training

  tokens combined;

- use source-level temperature sampling (`sqrt`, alpha `0.5`) instead of raw

  token-proportional sampling;

- add traceably licensed contemporary/natural Polish: open web, academic prose,

  cultural heritage text, guides, technical documentation/blogs, Q&A, and

  dialogue/instruction data;

- run aggressive exact, normalized, and near-duplicate removal;

- reserve the final **5-15%** of training for higher-quality sources rather than

  the largest sources;

- evaluate per-source perplexity and style contamination, not only global loss.



Current v0.3 source-ingestion status:



- `biblioteka_nauki`: prepared in the source registry as a direct-upstream

  rebuild target with per-document license and author metadata; not included in

  v{VERSION} parquets yet.

- `europeana`: prepared in the source registry as a direct-upstream rebuild

  target with per-record rights statements and creator metadata; raw SpeakLeash

  Europeana remains excluded.

- Europeana release policy: split conservatively at pre-1929 records for

  US-sensitive downstream reuse, and keep later/unknown records separately

  labeled or held until legal review.

- `european_hplt_v3_pl`: WDS bins 10+9 are included in v{VERSION} after contract

  validation. HPLT packaging is CC0, while underlying crawled web documents can

  carry independent rights; downstream near-dedup and web-content review remain

  recommended before training.



Current review artifacts:



- `configs/source_candidates_v0_3.json` — candidate decisions and license policy.

- `artifacts/source_license_review_v0_3.md` — source-by-source license review.

- `artifacts/source_candidate_audit_v0_3.md` — generated Hugging Face metadata audit.

- `artifacts/training_mix_v0_3.md` — example 1B-token training mix with legal sources capped at 15%.

- `artifacts/bartek_source_ingestion_plan_2026-07-02.md` — PR contract for

  Biblioteka Nauki and Europeana ingestion.



## Excluded sources (transparency)

Sources we reviewed and **deliberately left out** — part of the curation:



| source | reason |

|---|---|

{excl}



{DISCLAIMER}

## License & attribution

Released under **CC-BY-SA-4.0** (copyleft inherited from CC-BY-SA sources such as

Wikipedia/Wikisource/Wolne Lektury). Attribution due to each upstream (see datasheets)

and to **SpeakLeash** as the intermediate aggregator. Retroactive-removal policy: a

source that raises an objection is dropped from subsequent versions, recorded in the

CHANGELOG.



## Reproduce

```bash

python3 src/build_dynaword.py --all --speakleash-dir <speakleash_zst_dir> --out .

python3 src/make_docs.py

```

{phrase_frequency}

"""
    (ROOT / "README.md").write_text(readme)

    # CHANGELOG is append-only release history. Documentation regeneration must
    # never erase earlier releases or hand-reviewed legal/release notes.
    changelog_path = ROOT / "CHANGELOG.md"
    changelog = changelog_path.read_text() if changelog_path.exists() else "# Changelog\n"
    heading = f"## v{VERSION} ({RELEASE_DATE})"
    if heading not in changelog:
        entry = (
            f"{heading}\n\n"
            f"- Current release totals after parquet recount: {len(rows)} sources, "
            f"{tot_doc:,} docs, {tot_tok:,} tokens (tiktoken cl100k proxy).\n\n"
        )
        changelog = changelog.replace("# Changelog\n", f"# Changelog\n\n{entry}", 1)
        changelog_path.write_text(changelog)

    (ROOT / "LICENSE").write_text(
        "Polish DynaWord is released under Creative Commons Attribution-ShareAlike 4.0\n"
        "International (CC-BY-SA-4.0): https://creativecommons.org/licenses/by-sa/4.0/\n\n"
        "Per-source upstream licenses and attribution are documented in each\n"
        "data/<source>/<source>.md datasheet.\n")

    print(f"docs written: README + CHANGELOG + LICENSE + {len(rows)} datasheets")
    print(f"TOTAL {tot_doc:,} docs | {tot_tok/1e9:.2f}B tok | {tot_chr/1e9:.1f}B chars")


if __name__ == "__main__":
    main()