PKO Bank Polski Releases polish-roberta-8k, Beating Every Polish Encoder on 25 Tasks
A Polish RoBERTa variant now reads 8192 tokens, tops the KLEJ average, and ships in three sizes for edge deployment.
ProTakeaways
- New polish-roberta-8k encoder extends Polish RoBERTa's context from 512 to 8192 tokens.
- Two-stage training: freeze weights and adapt new position embeddings, then continue full pretraining on 150B tokens.
- Tops 25-task evaluation with 85.93 average, beating HerBERT, XLM-R, mmBERT, and EuroBERT on Polish.
- Distilled 12-layer and 6-layer variants released; progressive distillation outperforms direct compression.
- New FinBench suite of 7 Polish banking and finance tasks introduced alongside the paper.
- Uses Flash Attention and contamination-free packing; weights are compatible with standard HuggingFace RoBERTa code.
Polish NLP has been stuck with a familiar bottleneck: the strongest encoder models for the language, HerBERT and Polish RoBERTa, both cap out at 512 tokens. That's roughly one page of text, which is fine for tweets and headlines but useless for mortgage agreements, legal filings, or customer email threads. A team from Poland's National Information Processing Institute and PKO Bank Polski has now released polish-roberta-8k, an encoder that stretches that window to 8,192 tokens while beating every other Polish or multilingual encoder on a 25-task evaluation.
While decoder-only LLMs have recently dominated the NLP landscape, encoder-only architectures remain a cost-effective and parameter-efficient standard for discriminative tasks. However, classic encoders like BERT are limited by a short context window, which is insufficient for processing long documents. For non-English languages like Polish, that gap is worse: recent modern encoders such as ModernBERT, NeoBERT, and MosaicBERT were built primarily for English, and multilingual efforts like mmBERT and EuroBERT show weak downstream numbers on Polish tasks.
Two-stage surgery on an existing encoder
Rather than pretrain from scratch, the authors took the existing polish-roberta-large-v2 checkpoint and performed context surgery. In the first stage, the positional embedding layer was extended from 512 to 8192 tokens. The model was then trained on a corpus of approximately 150 billion tokens for one epoch. All model weights were frozen, and only the positional embedding layer was trained. The goal of this stage was to adapt the new layer without making drastic changes to the rest of the model's weights. The second stage then unfroze everything and continued pretraining for four more epochs.
Two efficiency tricks made 8k-token training tractable on a RoBERTa backbone:
- Flash Attention support was bolted onto the RoBERTa architecture to cut memory and compute.
- Contamination-free packing concatenates short documents into one 8k sequence but masks attention so tokens can't leak across document boundaries, avoiding the cross-contamination that naive packing causes.
Masked language modeling used a 20 percent masking rate with whole-word masking, and the final checkpoint is a merge of epochs 2, 3, and 4, chosen to balance short-text and long-text quality.
Distillation for edge use
For deployment on constrained hardware, the team also shipped compressed variants at 12 layers (291M params) and 6 layers (216M params), distilled by minimizing MSE between the teacher's and student's final-layer token representations. Attention-matrix distillation, which usually produces better students, was skipped because it becomes quadratically expensive at 8k tokens. Interestingly, progressive distillation, where you first distill to 12 layers, then use that as the teacher for the 6-layer model, beat direct 24-to-6 distillation on every task group except long texts.
Benchmark results
Evaluation spans 25 tasks: the nine-task KLEJ benchmark, a new seven-task financial suite called FinBench (Banking-Short/Long, Banking77, FiQA, FPB, GCN, Stooq), and nine other Polish tasks including EURLEX legal classification, MIPD disinformation detection, and a Polish-translated long-form IMDB.
| Model | Size | KLEJ | Long tasks | All 25 tasks |
|---|---|---|---|---|
| polish-roberta-8k | 443M | 88.52 | 83.16 | 85.93 |
| polish-roberta-large-v2 | 435M | 88.69 | 82.18 | 85.70 |
| herbert-large-cased | 355M | 87.83 | 81.67 | 84.88 |
| xlm-roberta-large | 560M | 87.29 | 81.10 | 83.20 |
| mmBERT-base | 307M | 83.17 | 82.08 | 80.24 |
| EuroBERT-610m | 608M | 80.10 | 83.24 | 78.89 |
The story is nuanced. On short tasks, the new model is basically tied with polish-roberta-large-v2. The real gap opens on the four long-text datasets (Banking-Long, MIPD, EURLEX, and long-IMDB) where an 8k context actually matters. Meanwhile, new modern multilingual encoders like EuroBERT-610m and mmBERT-base significantly lag behind Polish-specific models, though they hold up well on long-context tasks, likely thanks to rotary position embeddings.
What it's good for, and what it isn't
This is a discriminative-task workhorse, not a generative model. Use it when you need to fine-tune for classification, regression, NER, or retrieval on Polish documents that exceed a page of text: contract routing, complaint triage, long-form sentiment, or legal document tagging. The bank's internal evaluation is telling: a domain-adapted polish-roberta-8k hit 90 percent on banking email classification versus 82 percent for the HerBERT baseline, and both context extension and domain pretraining independently contributed to gains.
What it won't do: generate text, answer open questions, or handle instruction-style prompts. And the distilled 6-layer variant loses roughly 9 points on the DYK question-answering task from KLEJ, so it's not a drop-in for every downstream job.
Availability
All three sizes, along with a base-sized variant, are on Hugging Face under PKOBP/polish-roberta-8k and sdadas/polish-roberta-base-8k. Because the Flash Attention and packing modifications are numerically consistent with vanilla RoBERTa, the weights load in a standard transformers RobertaModel without custom code.