Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing

Minh Van Nguyen, Viet Dac Lai, Amir Pouran Ben Veyseh, Thien Huu Nguyen

Abstract

Trankit is a high-performance, memory-efficient NLP toolkit that provides a trainable pipeline for over 100 languages. By using a shared XLM-RoBERTa backbone combined with lightweight "Adapters," it achieves state-of-the-art accuracy on fundamental tasks like dependency parsing and sentence segmentation while remaining small enough to run multiple language pipelines simultaneously on a single GPU.

Introduction

Building a multilingual NLP pipeline usually involves a painful trade-off between performance and efficiency. State-of-the-art toolkits like Stanza or UDPipe deliver high accuracy but are memory-intensive. Because they train separate models for every language, their memory footprint grows linearly; loading pipelines for just a few languages can quickly exhaust GPU memory. Conversely, faster toolkits like spaCy often sacrifice accuracy, and many "multilingual" models struggle with raw text because they require external tokenizers.

The authors of Trankit developed a "best of both worlds" solution: a toolkit that leverages the power of large pretrained Transformers (like XLM-RoBERTa) without the massive memory overhead typically required to support dozens of languages.

Methods

Trankit’s architecture is built around a shared multilingual pretrained Transformer (XLM-RoBERTa). To achieve efficiency, the toolkit incorporates several key innovations:

Overview of the Trankit pipeline architecture showing the shared transformer backbone and task-specific modules.
  1. Adapters: Instead of fine-tuning the entire massive Transformer for every task and language, Trankit uses "Adapters"—small, trainable bottleneck layers inserted into the Transformer blocks. During training, the main Transformer is frozen, and only these tiny adapters are updated. This allows the toolkit to share the "heavy" part of the model across all languages, only swapping out a few megabytes of adapter weights for each specific language or task.
  2. Wordpiece-based Splitting: Unlike previous tools that use character-based sentence and token splitters, Trankit uses a wordpiece-based approach. This allows the model to better exploit contextual information, making it more robust to unusual punctuation or interjections.
  3. Joint Modeling: Trankit uses a multi-task head to jointly predict Part-of-Speech (POS) tags, morphological features, and dependency parses. This reduces error propagation and further saves memory.

Datasets

The researchers evaluated Trankit using:

  • Universal Dependencies (UD) v2.5: 90 treebanks covering 56 languages, the gold standard for evaluating fundamental NLP tasks like lemmatization and parsing.
  • NER Datasets: 11 public datasets for Named Entity Recognition, including AQMAR (Arabic), OntoNotes (English/Chinese), and CoNLL02/03.

Key Insights

  • Efficiency through Modularity: The "plug-and-play" adapter mechanism solves the scaling problem of multilingual NLP. Users can load 90 different language pipelines into just 4.9GB of memory because they all share the same 1.1GB Transformer backbone.
  • Contextual Tokenization: Moving from character-based to wordpiece-based tokenization provides a "semantic" understanding of where words and sentences should end, which is particularly helpful in noisy or informal text.
  • Adapters Prevent Interference: Ablation studies showed that training one giant multilingual model for everything performs worse than using adapters. Adapters help the model specialize for a specific language without being "distracted" by the features of other languages.

Key Results

Trankit significantly outperforms the previous state-of-the-art (Stanza) across most tasks.

Performance comparison of Trankit against Stanza, UDPipe, and spaCy across various Universal Dependency treebanks.
  • Accuracy: On the 90 UD treebanks, Trankit saw a +3.24% boost in sentence segmentation, +1.44% in POS tagging, and roughly +5% in dependency parsing (LAS).
  • Memory Efficiency: While Stanza’s model size for five languages exceeds 2.1GB, Trankit’s total size for the same languages is only 1.35GB. Loading all 90 supported pipelines takes only 4.9GB of VRAM.
  • NER: Trankit achieved competitive or superior F1 scores on 11 NER benchmarks compared to specialized toolkits like Flair.

Conclusion

Trankit represents a major step forward in making high-quality multilingual NLP accessible. While it is currently slower than non-Transformer toolkits like spaCy on CPUs, its superior accuracy and massive memory savings on GPUs make it an ideal choice for production environments requiring multi-language support. Future work will explore larger backbones and expanded task support.

Summary updated

BibTeX
@inproceedings{nguyen2021trankit,
  author = {Minh Van Nguyen and Viet Dac Lai and Amir Pouran Ben Veyseh and Thien Huu Nguyen},
  title = {{Trankit: A Light-Weight Transformer-based Toolkit for Multilingual Natural Language Processing}},
  booktitle = {EACL (System Demonstrations)},
  year = {2021},
  url = {https://openreview.net/forum?id=8ZbMhBuGxhB},
}
Figure