MarIA: Spanish Language Models

Asier Gutiérrez-Fandiño, Jordi Armengol-Estapé, Marc Pàmies, Joan Llop-Palao, Joaquín Silveira-Ocampo, Casimiro Pio Carrino, Aitor Gonzalez-Agirre, Carme Armentano-Oller, Carlos Rodriguez-Penagos, Marta VillegasarXiv 2021 · DOI

TL;DR

MarIA introduces a new state-of-the-art family of Spanish language models (RoBERTa and GPT-2 variants) trained on a massive, high-quality 570GB corpus from the National Library of Spain. By moving beyond translated datasets and Wikipedia-only training, MarIA sets a new benchmark for Spanish NLP, outperforming existing models across nearly all major natural language understanding (NLU) tasks.

What Problem Does This Paper Address?

Despite Spanish being the second most spoken language in the world, it has historically lagged behind English in the availability of massive, high-quality language models. Most existing Spanish models were either multilingual (like mBERT), trained on relatively small datasets, or relied heavily on Wikipedia and machine-translated English benchmarks.

The authors argue that these "translated" approaches often miss the nuances of native Spanish and that Wikipedia-centric training can lead to "data contamination," where models appear to perform well on benchmarks simply because the benchmark data was part of their training set. MarIA aims to close this gap by providing the industry and research community with models trained on a diverse, massive, and natively Spanish web archive.

Methods

The researchers developed four primary models: two encoders based on the RoBERTa architecture (Base and Large) and two decoders based on the GPT-2 architecture (Base and Large).

The core innovation lies in the data pipeline. The team processed 59TB of raw data from the Spanish Web Archive (crawled between 2009 and 2019) to produce a "clean" 570GB corpus containing 135 billion words. This involved:

  • Heuristic filtering: Removing low-quality documents, code snippets, and placeholder text.
  • Language Identification: A two-stage process using FastText for speed and a more accurate identifier for fine-grained filtering.
  • Deduplication: Using N-gram-based methods to ensure the model isn't over-exposed to repetitive web content.

The models were trained using a single-epoch regime, which is increasingly common for massive datasets to prevent overfitting while maximizing generalizability.

Datasets

The paper utilizes a wide array of datasets for both training and evaluation:

  • Pretraining Corpus: 570GB of clean Spanish text from the National Library of Spain (BNE).
  • SQAC (Spanish Question Answering Corpus): A newly introduced extractive QA dataset created specifically for this project. It contains 18,817 questions derived from 6,247 native Spanish contexts (Wikipedia, Wikinews, and the AnCora corpus).
  • Evaluation Benchmarks: The models were tested on 9 tasks, including text classification (MLDoc), Named Entity Recognition (CoNLL-NERC, CAPITEL-NERC), Paraphrase Identification (PAWS-X), Part-of-Speech tagging (UD-POS, CAPITEL-POS), Semantic Textual Similarity (STS), and Textual Entailment (XNLI).
Statistics for the range of interrogatives in the new SQAC dataset.

Key Insights and Ideas

  • Native Data Trumps Translation: Models trained on data originally written in Spanish generalize significantly better than those relying on translated datasets.
  • The Wikipedia Bias: The authors observed that models like BETO (trained on Wikipedia) performed very well on Wikipedia-based tasks but lagged behind MarIA on more diverse datasets like CAPITEL or the new SQAC. This suggests that MarIA is more robust for real-world web text.
  • Scale Still Matters: The RoBERTa-large model consistently outperformed the base version, particularly in complex tasks like Question Answering and Semantic Similarity, proving that Spanish NLP benefits from the same scaling laws seen in English models.
  • Smooth Convergence: Despite the massive data size, the generative GPT-2 models showed smooth perplexity curves, indicating high-quality data and stable training configurations.
Figure 1: Perplexity curves for GPT2 model.

Key Results

MarIA models established new state-of-the-art results for Spanish:

  • Question Answering: On the new SQAC dataset, RoBERTa-large achieved an F1 score of 0.8202, significantly outperforming BETO (0.7923) and mBERT (0.7562).
  • Named Entity Recognition: In the CAPITEL-NERC task, RoBERTa-large reached an F1 of 0.9051, a notable lead over previous monolingual models.
  • Semantic Similarity: On the STS task, MarIA models showed a nearly 3-point lead over Wikipedia-trained baselines, likely due to the broader diversity of the BNE training corpus.
  • Generative Performance: The GPT-2 models achieved impressive perplexity scores (10.02 for Train, 6.68 for Valid on the large model), demonstrating strong text completion capabilities.
Figure 2: Perplexity curves for GPT2-large model.

Limitations and Future Work

The authors identify several areas for growth:

  • Context Window: The current models are limited to a sequence length of 512 tokens. Future iterations aim to extend this to 1024 to handle longer documents better.
  • Data Diversity: While the BNE archive is massive, the authors plan to incorporate even more sources, such as books and the Spanish portion of Wikipedia, to create an even more "universal" Spanish model.
  • Bias Analysis: The authors acknowledge the need for deeper investigation into topic modeling and potential biases inherent in web-crawled data.
  • Efficiency: Future work will focus on scaling the models even further while improving inference efficiency to make them more accessible for real-world industry applications.

Summary updated

BibTeX
@misc{gutierrezfandino2021maria,
  author = {Asier Gutiérrez-Fandiño and Jordi Armengol-Estapé and Marc Pàmies and Joan Llop-Palao and Joaquín Silveira-Ocampo and Casimiro Pio Carrino and Aitor Gonzalez-Agirre and Carme Armentano-Oller and Carlos Rodriguez-Penagos and Marta Villegas},
  title = {{MarIA: Spanish Language Models}},
  year = {2021},
  eprint = {2107.07253},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.07253},
}
Figure