# Maskowane modelowanie języka (MLM)

EN: **Masked language modelling (MLM)** · id `mlm` · aliases: masked language modeling, masked language modelling, MLM, maskowane modelowanie języka

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Trenowanie i dostrajanie](https://aiatlasgraph.com/t/training.md) › [Trening od zera / pretraining](https://aiatlasgraph.com/t/pretraining.md) › Maskowane modelowanie języka (MLM)

## Description

- PL: Cel pretrainingu enkoderów: model odtwarza zamaskowane tokeny na podstawie kontekstu z obu stron.
- EN: A pretraining objective for encoders: the model restores masked tokens from context on both sides.

## In one sentence

- PL: Ćwiczenie, w którym model uczy się języka, zgadując słowa zakryte w zdaniu, jak w zadaniu z lukami.
- EN: An exercise in which a model learns language by guessing words hidden in a sentence, like a fill-in-the-blanks task.

## Problem it solves

- PL: Do rozumienia tekstu, na przykład przy wyszukiwaniu czy sortowaniu dokumentów, przydaje się patrzenie na zdanie z obu stron, nie tylko od lewej.
- EN: Understanding text, for search or sorting documents, benefits from reading a sentence from both sides, not only left to right.

## What it does

- PL: Jak ćwiczenie „uzupełnij luki” w podręczniku: żeby wpisać brakujące słowo, czytasz całe zdanie przed i po luce.
- EN: Like a textbook fill-in-the-gaps exercise: to supply the missing word, you read the whole sentence before and after the gap.

## Everyday example

- PL: Wyszukiwarka w sklepie internetowym rozumie, że „buty do biegania po lesie” i „obuwie terenowe” to to samo.
- EN: An online shop's search understands that 'shoes for running in the woods' and 'off-road footwear' mean the same thing.

## This concerns you if you…

- PL: budujesz wyszukiwanie lub klasyfikację tekstu
- PL: zastanawiasz się, czym model do rozumienia różni się od modelu do pisania
- EN: build text search or classification
- EN: wonder how a model for understanding differs from one for writing

## Keywords

BERT · RoBERTa · ModernBERT · masked language modeling · cloze task · bidirectional encoder

## How it works

- PL: Losowy odsetek tokenów zastępuje się tokenem maski, losowym tokenem lub pozostawia bez zmian. Enkoder z dwukierunkową uwagą przewiduje oryginalne tokeny, a strata obejmuje tylko wybrane pozycje.
- EN: A random share of tokens is replaced by a mask token, by random tokens or left unchanged. A bidirectional encoder predicts the originals, with loss applied only at the selected positions.

## Limits

- PL: Cel wykorzystuje stratę tylko na wybranych pozycjach i sam nie uczy generowania tekstu od lewej do prawej. Klasyczne modele enkoderowe trenowane w ten sposób wymagają innego celu lub architektury do swobodnego generowania, a specjalny token maski nie pojawia się podczas zwykłego użycia.
- EN: The objective applies loss only at selected positions and does not by itself train left-to-right text generation. Classic encoder models trained this way need another objective or architecture for free-form generation, and the special mask token is absent during normal use.

## Key terms

- PL: **token maski**: Specjalny symbol zastępujący ukryty token w przykładzie treningowym.
- PL: **dwukierunkowa uwaga**: Mechanizm, w którym pozycja korzysta z kontekstu zarówno przed sobą, jak i po sobie.
- EN: **mask token**: A special symbol replacing a hidden token in a training example.
- EN: **bidirectional attention**: Attention in which a position uses context from both before and after it.

## Know first

- [Tokenizacja tekstu (BPE, WordPiece, SentencePiece) (Text tokenisation (BPE, WordPiece, SentencePiece))](https://aiatlasgraph.com/t/tokenization.md)
- [Mechanizm self-attention (zapytania, klucze, wartości) (Self-attention (queries, keys, values))](https://aiatlasgraph.com/t/selfattention.md)

## Related topics

Untyped, symmetric "see also" links.

- [Przewidywanie następnego tokenu (modele autoregresyjne) (Next-token prediction objective)](https://aiatlasgraph.com/t/nexttoken.md)

## Sources

- [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](<https://arxiv.org/abs/1810.04805>) `bert-2018` · by Jacob Devlin, Ming-Wei Chang, Kenton Lee, Kristina Toutanova

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/mlm · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
