File size: 11,854 Bytes
42e8ab6
ca95db6
 
42e8ab6
ca95db6
 
 
 
 
 
 
 
deaad46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42e8ab6
ca95db6
 
 
c91d182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178ad06
 
ca95db6
178ad06
 
 
 
ca95db6
178ad06
ca95db6
7a9dd2c
 
178ad06
ca95db6
178ad06
 
ca95db6
178ad06
 
 
ca95db6
178ad06
 
 
 
ca95db6
178ad06
ca95db6
178ad06
 
ca95db6
178ad06
 
 
 
 
 
ca95db6
178ad06
ca95db6
178ad06
 
 
 
ca95db6
178ad06
ca95db6
178ad06
 
 
 
ca95db6
178ad06
 
 
ca95db6
178ad06
 
 
 
 
 
ca95db6
 
 
178ad06
 
ca95db6
178ad06
ca95db6
178ad06
ca95db6
178ad06
ca95db6
 
 
178ad06
 
ca95db6
178ad06
 
ca95db6
178ad06
ca95db6
178ad06
 
 
ca95db6
 
 
178ad06
 
 
 
 
 
 
 
 
 
 
 
 
ca95db6
 
 
178ad06
 
ca95db6
178ad06
ca95db6
 
 
 
 
 
178ad06
ca95db6
 
 
 
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
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
---
language:
- pl
license: mit
library_name: transformers
pipeline_tag: text-generation
tags:
- polish
- gpt2
- nanogpt
- tokenizer-ablation
- research
model-index:
- name: GoLLeM-45M-PL
  results:
  - task:
      type: text-classification
      name: Sentiment Classification (zero-shot, log-likelihood)
    dataset:
      type: allegro/klej-polemo2-in
      name: PolEmo2.0-IN
      split: test
      config: polemo2-in
    metrics:
    - type: accuracy
      value: 47.2
      name: Accuracy (PMI-normalized)
      verified: false
    - type: accuracy
      value: 40.0
      name: Majority-class baseline
      verified: false
  - task:
      type: text-classification
      name: Topic Classification (zero-shot, log-likelihood)
    dataset:
      type: sdadas/8tags
      name: 8Tags
      split: test
    metrics:
    - type: accuracy
      value: 31.5
      name: Accuracy (PMI-normalized)
      verified: false
    - type: accuracy
      value: 16.5
      name: Majority-class baseline
      verified: false
  - task:
      type: text-generation
      name: Language Modeling
    dataset:
      type: speakleash
      name: SpeakLeash held-out (private, 1999 docs)
    metrics:
    - type: bits_per_byte
      value: 1.2114
      name: BPB (mean of 3 seeds)
      verified: false
    - type: bits_per_byte
      value: 0.0100
      name: BPB std. dev. across seeds
      verified: false
---

# GoLLeM-45M-PL

A GPT-2 model (42.5M parameters) trained from scratch on 2.96 GB of Polish text,
with a dedicated Polish BPE tokenizer (32,768 entries).

The model is an **artifact of a research experiment**, not a practical tool.
The question: *does a dedicated Polish tokenizer produce a better model than the GPT-2
tokenizer under the same training budget?* The answer: **it is not better — it is
comparable at 2.5× lower cost.**

Code, data and full methodology: https://github.com/KateMajzel/gollem-pl

Mirror: [SlayerLab/GoLLeM-45M-PL](https://huggingface.co/SlayerLab/GoLLeM-45M-PL).

## Usage

```python
from transformers import pipeline

pipe = pipeline("text-generation", model="KateMajzel/GoLLeM-45M-PL")
print(pipe("W lesie mieszkał mały", max_new_tokens=50)[0]["generated_text"])
```

Default generation parameters: `do_sample=True`, `temperature=0.8`, `top_p=0.9`,
`repetition_penalty=1.15`. Greedy decoding falls into repetition loops — typical for
models of this size. The 199 unused filler tokens (32,569–32,767) are blocked via
`bad_words_ids`.

## Results

BPB on the private held-out set (1,999 documents, an identical 2,767,440 bytes for
each model; means over 3 seeds for R1 and R2a):

| run | tokenizer | budget | BPB ↓ | sd | parameters | time |
|---|---|---|---|---|---|---|
| **R1** (this model) | Polish, 32,768 | 2.96 GB | 1.2114 | 0.0100 | 42.5M | **49.7 min** |
| R2a | GPT-2, 50,257 | 2.96 GB — same bytes | 1.1946 | 0.0035 | 51.5M | 122.4 min |
| R2b | GPT-2, 50,257 | 2,970 steps — same tokens | 1.2756 | (n=1) | 51.5M | 62.4 min |
| R3 | GPT-2 zero-shot | — | 2.9555 | (n=1) | 124M | — |

Zero-shot benchmarks (log-likelihood with domain PMI normalization):

| task | R1 | R2a | GPT-2 | majority class | random |
|---|---|---|---|---|---|
| PolEmo2-IN | 47.2% | 43.8% | 20.8% | 40.0% | 25.0% |
| 8Tags | 31.5% | 29.8% | 17.8% | 16.5% | 12.5% |

### Interpretation

Four independent measurements (BPB, PolEmo2, 8Tags, the private held-out set) show no
significant advantage for either tokenizer under an equal text budget, and their
directions are inconsistent. The decisive observation: **the BPB difference between two
seeds of the same model (0.0186) exceeds the difference between models with different
tokenizers (0.0124).**

The advantage lies in cost. Under a matched compute budget (R1 vs R2b) the Polish
tokenizer wins by 5.30% BPB — 6.4 standard deviations. The Bielik v3 PL team reached
the same conclusion independently at 11B scale (arXiv 2604.10799).

### A note on perplexity

PPL/token is 30.7 for R1 and 5.8 for R2a, which would suggest a fivefold advantage for
GPT-2. This is an artifact: models with different tokenizers predict units of different
difficulty. **Perplexity is not comparable between them.** The only correct metric is
bits-per-byte.

## Tokenizer

Byte-level BPE, 32,568 entries + 200 special. 27.9% of entries contain Polish
diacritics, lossless round-trip, zero tokens unreachable through merges.

| | this tokenizer | GPT-2 |
|---|---|---|
| bytes/token (corpus) | 4.050 | 2.066 |
| bytes/token (held-out) | 4.103 | 2.134 |
| density | **1.96×** | 1.00× |

## Training data

2.96 GB, 803,177 documents, [SpeakLeash](https://speakleash.org/): 37% encyclopedia and
literature, 22% forums, 27% web, 11% journalism and science, 3% official/administrative
texts.

Deliberately excluded: translations and subtitles (translationese), synthetic text, song
lyrics (copyright), raw Common Crawl. Dataset licensing is handled on the SpeakLeash side.

## Architecture

8 layers × 8 heads × 512 dimensions, 1,024-token context, 42.5M parameters
(25.7M non-embedding), 731M training tokens (17.2 per parameter),
AdamW lr 1e-3 → 1e-4, bfloat16, 1 epoch, 1× RTX 5080.

## Limitations

- **Scale.** The model produces correct Polish at the sentence level, but hallucinates
  facts and loses coherence after a few sentences. An example from generation:
  *"wieś znalazła się w powiecie częstochowskim, gminie Łęczna"* ("the village was located
  in Częstochowa County, Łęczna municipality") — both names exist, the combination is false.
- **Base model.** Text continuation only; no instruction tuning and no safety filtering.
- **Internet forum data.** The model may reproduce the biases and language present there.
  It is not suitable for end-user applications — children in particular — without human
  oversight.
- **A single scale and a single configuration.** The results apply to 42M parameters and
  3 GB of data.
- **Register depends on the data mix.** Given a children's fairy-tale prompt, the model
  responds in the language of forums or encyclopedia entries.
- The corpus contains Windows line endings (`\r\n`), which the model reproduces.

## Reproducibility

Code, configurations, evaluation scripts and a description of five methodological
pitfalls: https://github.com/KateMajzel/gollem-pl

Based on [nanoGPT](https://github.com/karpathy/nanoGPT) (MIT, Andrej Karpathy).

## Citation

```bibtex
@misc{gollem45mpl,
  title  = {GoLLeM-45M-PL: a tokenizer ablation for a Polish language model},
  author = {Majzel-Pośpiech, Katarzyna},
  year   = {2026},
  url    = {https://huggingface.co/KateMajzel/GoLLeM-45M-PL}
}
```


---

# GoLLeM-45M-PL

Model GPT-2 (42,5 mln parametrów) wytrenowany od zera na 2,96 GB polskiego tekstu,
z dedykowanym polskim tokenizerem BPE (32 768 pozycji).

Model jest **artefaktem eksperymentu badawczego**, nie narzędziem użytkowym.
Pytanie: *czy dedykowany tokenizer polski daje lepszy model niż tokenizer GPT-2 przy
tym samym budżecie treningowym?* Odpowiedź: **nie daje lepszego — daje porównywalny
2,5× taniej.**

Kod, dane i pełna metodologia: https://github.com/KateMajzel/gollem-pl

Kopia lustrzana: [SlayerLab/GoLLeM-45M-PL](https://huggingface.co/SlayerLab/GoLLeM-45M-PL).

## Użycie

```python
from transformers import pipeline

pipe = pipeline("text-generation", model="KateMajzel/GoLLeM-45M-PL")
print(pipe("W lesie mieszkał mały", max_new_tokens=50)[0]["generated_text"])
```

Domyślne parametry generacji: `do_sample=True`, `temperature=0.8`, `top_p=0.9`,
`repetition_penalty=1.15`. Dekodowanie zachłanne wpada w pętle powtórzeń — typowe dla
modeli tej wielkości. 199 nieużywanych tokenów wypełniających (32 569–32 767)
zablokowano przez `bad_words_ids`.

## Wyniki

BPB na prywatnym held-oucie (1 999 dokumentów, identyczne 2 767 440 bajtów dla
każdego modelu; średnie z 3 ziaren dla R1 i R2a):

| przebieg | tokenizer | budżet | BPB ↓ | sd | parametry | czas |
|---|---|---|---|---|---|---|
| **R1** (ten model) | polski, 32 768 | 2,96 GB | 1,2114 | 0,0100 | 42,5 M | **49,7 min** |
| R2a | GPT-2, 50 257 | 2,96 GB — te same bajty | 1,1946 | 0,0035 | 51,5 M | 122,4 min |
| R2b | GPT-2, 50 257 | 2 970 kroków — te same tokeny | 1,2756 | (n=1) | 51,5 M | 62,4 min |
| R3 | GPT-2 zero-shot | — | 2,9555 | (n=1) | 124 M | — |

Benchmarki zero-shot (log-likelihood z normalizacją PMI domenową):

| zadanie | R1 | R2a | GPT-2 | klasa większościowa | losowo |
|---|---|---|---|---|---|
| PolEmo2-IN | 47,2% | 43,8% | 20,8% | 40,0% | 25,0% |
| 8Tags | 31,5% | 29,8% | 17,8% | 16,5% | 12,5% |

### Interpretacja

Cztery niezależne pomiary (BPB, PolEmo2, 8Tags, prywatny held-out) nie wykazują
istotnej przewagi żadnego tokenizera przy równym budżecie tekstu, a ich kierunki są
niespójne. Rozstrzygająca obserwacja: **różnica BPB między dwoma ziarnami tego samego
modelu (0,0186) przewyższa różnicę między modelami o odmiennych tokenizerach (0,0124).**

Przewaga leży w koszcie. Przy wyrównanym budżecie obliczeniowym (R1 vs R2b) tokenizer
polski wygrywa o 5,30% BPB — 6,4 odchylenia. Ten sam wniosek uzyskał niezależnie zespół
Bielika v3 PL na skali 11B (arXiv 2604.10799).

### Uwaga o perplexity

PPL/token wynosi 30,7 dla R1 i 5,8 dla R2a, co sugerowałoby pięciokrotną przewagę
GPT-2. To artefakt: modele o różnych tokenizerach przewidują jednostki różnej trudności.
**Perplexity jest między nimi nieporównywalna.** Jedyną poprawną metryką jest
bits-per-byte.

## Tokenizer

Byte-level BPE, 32 568 pozycji + 200 specjalnych. 27,9% pozycji z polskimi
diakrytykami, round-trip bezstratny, zero tokenów nieosiągalnych przez merge.

| | ten tokenizer | GPT-2 |
|---|---|---|
| bajty/token (korpus) | 4,050 | 2,066 |
| bajty/token (held-out) | 4,103 | 2,134 |
| gęstość | **1,96×** | 1,00× |

## Dane treningowe

2,96 GB, 803 177 dokumentów, [SpeakLeash](https://speakleash.org/): 37% encyklopedia
i literatura, 22% fora, 27% web, 11% publicystyka i nauka, 3% teksty urzędowe.

Celowo wykluczone: tłumaczenia i napisy (translationese), tekst syntetyczny, teksty
piosenek (prawa autorskie), surowy Common Crawl. Licencje zbiorów po stronie SpeakLeash.

## Architektura

8 warstw × 8 głowic × 512 wymiarów, kontekst 1 024 tokeny, 42,5 M parametrów
(25,7 M niezanurzeniowych), 731 mln tokenów treningowych (17,2 na parametr),
AdamW lr 1e-3 → 1e-4, bfloat16, 1 epoka, 1× RTX 5080.

## Ograniczenia

- **Skala.** Model produkuje poprawną polszczyznę na poziomie zdania, ale halucynuje
  fakty i traci spójność po kilku zdaniach. Przykład z generacji: *„wieś znalazła się
  w powiecie częstochowskim, gminie Łęczna"* — obie nazwy istnieją, zestawienie jest
  fałszywe.
- **Model bazowy.** Wyłącznie kontynuacja tekstu; bez dostrajania instrukcyjnego
  i bez filtrowania bezpieczeństwa.
- **Dane z forów internetowych.** Model może odtwarzać obecne tam uprzedzenia i język.
  Nie nadaje się do zastosowań z udziałem użytkownika końcowego — w szczególności
  dzieci — bez nadzoru człowieka.
- **Jedna skala i jedna konfiguracja.** Wyniki dotyczą 42 M parametrów i 3 GB danych.
- **Rejestr zależny od miksu danych.** Przy prompcie z bajki dla dzieci model
  odpowiada językiem forów lub haseł encyklopedycznych.
- Korpus zawiera windowsowe końce linii (`\r\n`), które model odtwarza.

## Odtwarzalność

Kod, konfiguracje, skrypty ewaluacyjne i opis pięciu pułapek metodologicznych:
https://github.com/KateMajzel/gollem-pl

Bazuje na [nanoGPT](https://github.com/karpathy/nanoGPT) (MIT, Andrej Karpathy).

## Cytowanie

```bibtex
@misc{gollem45mpl,
  title  = {GoLLeM-45M-PL: ablacja tokenizera dla polskiego modelu językowego},
  author = {Majzel-Pośpiech, Katarzyna},
  year   = {2026},
  url    = {https://huggingface.co/KateMajzel/GoLLeM-45M-PL}
}
```