A General-Purpose Multilingual Document Encoder

Onur Galoglu, Robert Litschko, Goran GlavasarXiv 2023 · DOI

Introduction

The advancement of "massively multilingual" models like XLM-R and mBERT has revolutionized natural language processing by creating shared vector spaces for over a hundred languages. However, these models primarily operate as flat sequence processors, which presents significant hurdles for document-level tasks. Standard Transformers are constrained by a fixed context window (typically 512 tokens), forcing researchers to either truncate long texts or fragment them into independent chunks. This results in "structural blindness," where the natural hierarchy of sentences and paragraphs is ignored, and global context is lost.

To address these challenges, we present the Hierarchical Multilingual Document Encoder (HMDE). HMDE is designed to represent long documents across many languages in a single vector space, maintaining structural integrity while scaling efficiently to longer sequences.

Methods: The HMDE Architecture

The core innovation of HMDE lies in its two-level hierarchical structure, which mirrors the natural composition of documents.

The HMDE architecture uses a two-level Transformer to encode documents hierarchically.

As illustrated in Figure 1, the model consists of:

  1. Lower-Level Sentence Encoder: A pretrained LaBSE (Language-Agnostic BERT Sentence Embedding) model processes individual sentences into fixed-length vectors.
  2. Upper-Level Document Contextualizer: A shallow, 2-layer Transformer takes these sentence vectors as input. It applies self-attention across the sentences to produce contextualized representations, which are then pooled into a single document-level embedding.

Contrastive Pretraining

Training a document encoder requires large-scale cross-lingual data. HMDE leverages Wikipedia’s inter-language links as a source of supervision. If an article exists in both English and Italian, these versions are treated as a positive pair in a contrastive learning objective. To further refine the model's semantic understanding, the authors employ "hard negatives" derived from Wikipedia’s category hierarchy. For instance, an article about "France" might be paired with an article about "Switzerland" as a negative example, forcing the model to distinguish between closely related entities within the same category.

Experimental Setup

The model was pretrained on the Wiki-40B dataset using two distinct configurations:

  • XLW-4L: Focused on high-resource languages (English, French, German, Italian).
  • XLW-12L: A linguistically diverse set including Arabic, Chinese, Japanese, and Turkish.

Evaluation was conducted on two primary benchmarks:

  • MLDOC (Classification): A subset of the Reuters news corpus covering 8 languages.
  • CLEF-2003 (Retrieval): A classic benchmark for cross-lingual information retrieval (CLIR) across 9 language pairs.

Key Results and Analysis

HMDE demonstrates substantial improvements over both standard multilingual transformers and existing long-document models.

Cross-Lingual Information Retrieval (CLIR)

The most significant gains were observed in unsupervised retrieval tasks. HMDE achieved an average Mean Average Precision (MAP) of 0.249, nearly doubling the performance of the mLongformer (0.109) and significantly outperforming the LaBSE-Seg baseline (0.159), which simply averages sentence embeddings.

Performance comparison on Cross-Lingual Information Retrieval (CLIR) across various language pairs.

As shown in Figure 4, HMDE consistently outperforms baselines across diverse language pairs, such as English-Finnish and German-Russian. This suggests that the hierarchical contextualization of sentences is crucial for capturing the global semantics necessary for document matching.

Cross-Lingual Document Classification (XLDC)

In classification tasks, HMDE reached an average accuracy of 86.8%, surpassing standard models like XLM-R (83.0%) and mBERT (82.0%). It also slightly exceeded the performance of the mLongformer (86.1%), proving its versatility across different document-level objectives.

Zero-Shot Generalization and Data Quality

A key finding was HMDE's ability to generalize to languages not seen during document-level pretraining. For example, the model performed exceptionally well on Finnish retrieval, despite Finnish not being in the XLW-4L training set. This is attributed to the underlying LaBSE encoder's existing multilingual knowledge; the upper layers learn a language-agnostic method for combining sentences that transfers across the entire model.

Furthermore, results indicated that training on a larger volume of high-quality data in fewer languages (XLW-4L) often yielded better results than a smaller, more diverse dataset (XLW-12L). This suggests that for document-level encoders, the quality of the underlying sentence representations and raw data volume are primary drivers of performance.

Conclusion and Future Work

HMDE provides a scalable and effective solution for multilingual document encoding. By adopting a hierarchical approach, it avoids the quadratic complexity of standard Transformers while capturing essential global context. While highly effective, the model is currently limited by the language support of its base encoder (LaBSE) and the encyclopedic nature of its Wikipedia-based training data. Future research may explore integrating sparse attention mechanisms or deeper hierarchical structures to further enhance document representations.

Summary updated

BibTeX
@misc{galoglu2023general,
  author = {Onur Galoglu and Robert Litschko and Goran Glavas},
  title = {{A General-Purpose Multilingual Document Encoder}},
  year = {2023},
  eprint = {2305.07016},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.07016},
}
Figure