polish-dynaword / BLOGPOST.md
kacperwikiel's picture
Squash: collapse LFS history to reclaim private storage
cfe406c
|
Raw
History Blame Contribute Delete
7.43 kB

Licensed to Train: a 100% openly-licensed Polish LLM stack

Draft — Slayer Labs. Doubles as the skeleton for a short tech report.

TL;DR

  • We built Polish DynaWord, a Polish pre-training corpus where every single token is openly licensed for model training, with a documented legal basis per source.
  • 5.64B tokens · 2.38M documents · 6 sources — larger than Danish Dynaword (4.8B), the reference edition in the family.
  • We trained a dedicated 32k Polish BPE that encodes Polish 1.75× tighter than Bielik's tokenizer and 1.58× tighter than Llama-3 — at a quarter of Llama-3's vocabulary.
  • We are training a small LM from scratch on this corpus with a modern stack (modded-nanogpt: Muon, RoPE, RMSNorm, QK-norm, SwiGLU). The result is a model whose entire provenance — data, tokenizer, and training — is legally defensible end-to-end.
  • Everything is released: corpus, tokenizer, and reproducible build scripts.

1. The problem: clean data is the hard part

Most "open" pre-training datasets ride on Common Crawl, whose underlying content carries ambiguous rights. That ambiguity is not academic: projects have been pulled or never released over exactly this (the Dynaword paper, arXiv:2508.02271, cites a shut-down music generator, a withdrawn Danish encoder, and the never-released Nordic Pile).

For Polish specifically, there was no openly-licensed, traceable, continuously-maintained corpus in the Dynaword family. Danish, Norwegian, Swedish, Icelandic — yes. Polish — no. That gap is the project.

The interesting work is not downloading text. It is the licensing, deduplication, decontamination, and provenance — putting each source in the right place with the right paper trail. That is what takes time; the bytes are commodity.

2. The corpus

We follow the Dynaword guidelines literally:

  1. Open & traceable licensing. Not "this is public domain" but why — statutory basis or upstream license, documented per source.
  2. Reproducibility. A single script rebuilds the corpus from sources.
  3. Documented. A datasheet per source.
  4. Extensibility. Versioned; new sources by contribution.

Sources (v0.1):

source license documents tokens
Legal & official (EU law + parliamentary) CC-BY-4.0 / official documents (art. 4) 567k 4.0B
Encyclopedic & reference (Wikipedia + Wikisource) CC-BY-SA-3.0 1.80M 1.5B
Literature & books (public-domain collections) CC-BY-SA-4.0 / public domain 6k 0.1B
total 2.38M 5.64B

Only human-authored text — no synthetic, machine-translated, or auto-transcribed data. Gates are deliberately minimal (drop short docs, non-Polish, exact duplicates, OCR garble); heavy quality filtering and mix-weighting belong downstream, in training, not in the released corpus.

What we excluded, and why (transparency matters as much as inclusion):

  • Movie/TV subtitles — derivative of copyrighted dialogue; mostly unlicensed uploads. This is the exact lesson Danish Gigaword learned with OpenSubtitles. Out.
  • A large cultural-heritage aggregate — mixed per-record rights (public-domain and rights-reserved in one bucket). Needs per-record rights filtering before any inclusion.
  • A "novels" corpus — labelled permissive, but likely contains in-copyright contemporary works. Pending title-level verification.

The data itself comes from an open redistribution of these upstream sources; the redistributor is credited, and each upstream license/attribution is preserved.

Sidebar: the download was its own little puzzle

The source host caps throughput at ~1.5 MB/s per IP (confirmed identical across three machines — it is per-IP policing, not our link). Single-stream TCP collapsed under packet loss; parallel connections plateaued at the per-IP ceiling. The fix was simply more IPs: we sharded the corpus — and byte-range-split the 8.9 GB long-pole file — across three machines in parallel, reassembling on the target box. A reminder that the ceiling is rarely where you first think it is.

3. The tokenizer: a Polish BPE that beats Bielik

nanoGPT-style stacks default to GPT-2's byte-level BPE — which is terrible on Polish. So we trained a 32k byte-level Polish BPE on a domain-balanced ~1 GB sample (capping the 71%-legal skew so the tokenizer doesn't overfit to legalese). Training took 51 seconds.

Then we measured fertility (tokens per word) on held-out Polish, against the obvious baselines:

tokenizer fertility

tokenizer vocab tok/word vs ours
Polish-32k (ours) 32,768 1.74 1.00×
Llama-3 128,000 2.74 1.58× worse
Bielik-11B-v3 32,000 3.04 1.75× worse
GPT-2 50,257 3.66 2.10× worse

The headline: our 32k Polish BPE encodes Polish 1.75× more efficiently than Bielik's — at the same vocabulary size. And Bielik is worse than Llama-3, despite Llama having a 4× larger vocab.

Why? Bielik-11B-v3 is built on Mistral and inherited Mistral's tokenizer — a general multilingual 32k vocab, never trained on Polish. It never got a Polish-native tokenizer. A dedicated Polish BPE sees the same text roughly twice as densely.

Practically this means: ~2× more text per context window, and the same FLOPs train on ~2× more Polish. (Caveat for the rigorous: the held-out sample is in-domain Wikipedia; all four tokenizers see identical text, and the 1.75× gap is too large to be a domain artifact, but a fully out-of-domain re-test strengthens the published number.)

4. The model: clean provenance, end to end

A model is only as "open" as its entire lineage. Continually pre-training someone else's checkpoint inherits that checkpoint's data-provenance questions. So we train from scratch on the clean corpus.

We use modded-nanogpt (Keller Jordan's speedrun stack — Muon optimizer, RoPE, RMSNorm, QK-norm, SwiGLU, fp8): a modern 124M-scale architecture, already validated, far more FLOP-efficient than vanilla GPT-2. We swap in our Polish BPE and retokenize the corpus into training shards.

Target: a 124M (and later ~350M) Polish LM trained entirely on openly-licensed data, in ~one night on a single H100.

[Results pending] — loss curves, held-out perplexity, and a Polish eval (PolNative) to go here. The claim we are validating, à la the Dynaword paper's training experiments: clean, openly-licensed data is enough to train a capable Polish LM.

5. Why it matters

Put together, this is a Polish language-model stack where you can point at every component — the data, the tokenizer, the training run — and trace it to a license that permits the use. No scraped text of unknown rights. No copyrighted media. That is the spirit of the Open Source AI definition, applied end-to-end, for a language that didn't have it.

6. Release

  • Corpus: SlayerLab/polish-dynaword (HF dataset, CC-BY-SA-4.0; per-source datasheets).
  • Tokenizer: polish_bpe_32k.json.
  • Code: reproducible build + tokenization + training scripts.

Built on the shoulders of the Dynaword guidelines (Enevoldsen et al., 2025) and the open-data communities behind every source.