Language Modelling with Pixels

Phillip Rust, Jonas F. Lotz, Emanuele Bugliarello, Elizabeth Salesky, Miryam de Lhoneux, Desmond Elliott

TL;DR

PIXEL (Pixel-based Encoder of Language) is a language model that "sees" text as images instead of processing it as a sequence of discrete tokens. By pretraining a Vision Transformer to reconstruct masked patches of rendered text, the authors bypass the "vocabulary bottleneck," enabling the model to generalize to unseen scripts and resist character-level noise far better than traditional models like BERT.

What Problem Does This Paper Address?

Most modern language models rely on a fixed vocabulary of subword units. This creates a "vocabulary bottleneck" with three major pain points:

  1. Scaling to Thousands of Languages: A fixed vocabulary can only represent so many unique characters or subwords. When a model encounters a script it wasn't trained on (like Coptic or Amharic), it sees a sea of [UNK] (unknown) tokens and fails.
  2. Orthographic Sensitivity: Traditional tokenizers are brittle. A single typo or the use of a "visually confusable" character (e.g., replacing a Latin 'a' with a Cyrillic 'а') can completely change how a word is tokenized, confusing the model.
  3. The Embedding Trade-off: Large vocabularies require massive embedding matrices, while small vocabularies (like bytes) lead to prohibitively long sequences that are computationally expensive to process.

PIXEL addresses these by treating language as a visual recognition task, removing the need for a predefined vocabulary entirely.

Methods

PIXEL is built on the Masked Autoencoding Vision Transformer (ViT-MAE) architecture. The process works as follows:

  1. Text Rendering: A text renderer draws sentences onto a blank RGB image.
  2. Patching: The image is split into $16 \times 16$ pixel patches.
  3. Span Masking: Instead of masking random patches, PIXEL uses a novel Patch Span Masking algorithm (Algorithm 1 in the paper). It masks contiguous spans of patches (roughly corresponding to words or phrases) to encourage the model to learn higher-level linguistic abstractions.
  4. Pretraining: The encoder processes only the visible patches. A lightweight decoder then attempts to reconstruct the raw pixels of the masked patches.
  5. Finetuning: For downstream tasks, the decoder is discarded and replaced with a task-specific head (like an MLP for classification).
Figure 1: Overview of PIXEL’s architecture. Following He et al. (2022), we use a masked autoen- coder with a ViT architecture and a lightweight decoder for pretraining (left). At finetuning time (right), the decoder is replaced by a task-specific classification head that sits on top of the encoder.

Datasets

  • Pretraining: PIXEL was trained on the same data as the original BERT: English Wikipedia and Bookcorpus (~3.1 billion words). Crucially, this data is almost entirely English (Latin script).
  • Evaluation: The authors tested PIXEL across 32 typologically diverse languages and 14 different scripts using:
  • Universal Dependencies (v2.10): For Part-of-Speech (POS) tagging and dependency parsing.
  • MasakhaNER: Named Entity Recognition for African languages.
  • GLUE & SQuAD: Standard English benchmarks for semantic understanding.
  • TyDiQA: Question answering in diverse languages.
  • Zeroé: A benchmark for evaluating robustness to orthographic attacks.

Key Insights and Ideas

  • Orthographic Transfer: Because PIXEL operates on pixels, it can exploit visual similarities between scripts. It doesn't need to have seen a specific language's "tokens" to understand its structure if the script looks similar to something it knows.
  • Zero-Shot Script Support: PIXEL can process any language that can be rendered by a computer. It natively supports emojis, right-to-left text, and complex ligatures without any changes to the model architecture.
  • Visual Robustness: Since the model learns the "shape" of words, it is naturally more resistant to character-level noise.
Visual explanations showing PIXEL's robustness to "confusable" character substitutions in NLI tasks.

Key Results

  • Outperforming BERT on Unseen Scripts: Despite being trained only on English, PIXEL crushed BERT on scripts not found in the pretraining data. For example, on Coptic (where BERT has a 93% [UNK] rate), PIXEL achieved 96.0% POS accuracy compared to BERT’s 26.5%.
  • Superior Robustness: In orthographic attack scenarios (like replacing letters with visually similar Unicode characters), BERT’s performance on POS tagging plummeted to 38%, while PIXEL maintained an accuracy above 92%.
  • The Latin Script Trade-off: PIXEL is slightly weaker than BERT on Latin-script languages (like English). On English POS tagging, PIXEL scored 96.7% vs. BERT's 97.2%. The authors suggest PIXEL may require more pretraining steps to reach the same level of semantic abstraction as subword-based models.

Limitations and Future Work

  • Sample Efficiency: PIXEL currently seems less sample-efficient than token-based models for high-level semantic tasks (like those in GLUE).
  • Right-to-Left (RTL) Challenges: The current implementation processes RTL sentences from the "end" to the "beginning" visually, which might lead to suboptimal feature learning.
  • No Generation: As an encoder-based model, PIXEL cannot currently be used for generative tasks like translation or summarization.
  • Computational Overhead: Rendering text as images and storing them requires more disk space and preprocessing time than simple text files.

Future work aims to pretrain PIXEL on multilingual data and investigate inductive biases that could help the model capture longer-range dependencies more effectively.

Summary updated

BibTeX
@inproceedings{rust2023language,
  author = {Phillip Rust and Jonas F. Lotz and Emanuele Bugliarello and Elizabeth Salesky and Miryam de Lhoneux and Desmond Elliott},
  title = {{Language Modelling with Pixels}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
}
Figure