Masking is a technique in deep learning that hides or ignores specific parts of the data. It aims to control how information is processed and to draw out attention to, or dependence on, particular information while the model is trained. It is mainly used with the self-attention mechanism in Transformer models, where hiding specific parts of the input sequence controls the flow of contextual information. It is also used as a form of data augmentation, where hiding particular words strengthens the model's ability to infer meaning. For these reasons, masking is regarded as a powerful technique for improving the performance of deep learning models.
Glossary
Masking
Updated:
![A diagram showing two uses of masking. On the left, as in BERT, part of the sentence "I like [MASK] a lot ." is hidden and fed into a Transformer, which predicts the hidden word "cats" from the surrounding context. On the right, a causal mask table: rows are the word currently being processed and columns are the words it attends to. Cells for the word itself and earlier words are filled and may be attended to, while cells for future words in the upper right are hidden with dashed outlines](/note/images/articles/glossary/masking.en.png)
Explanation
Where It Is Used
Masking is used in a variety of tasks. In natural language processing (NLP), for example, Transformer-based models such as BERT are trained on a task that masks words in the input sentence and predicts them. In speech processing, ignoring specific parts of the audio signal improves robustness to noise and raises speech recognition accuracy. In image processing, a technique called Masked Image Modeling hides specific regions of an image and reconstructs the information in those regions, strengthening visual understanding. In reinforcement learning, having the agent ignore specific information in the state encourages better exploration and strategies, and in anomaly detection, masking part of the normal data improves the model's ability to detect anomalies.
FAQ
- Q. What is masking used for?
- A.
It prevents the model from relying too heavily on specific information, enabling more context-based understanding and more robust predictions.
- Q. How is it used in Transformers?
- A.
In the self-attention mechanism, a "causal mask" keeps the model from seeing future words, and methods like BERT's mask random words.
- Q. In what fields is it used?
- A.
It is widely used in tasks that need to learn with part of the information restricted, such as natural language processing, speech recognition, image generation, reinforcement learning, and anomaly detection.
