Current pre-trained cross-lingual sentence encoders approaches use sentence-level objectives only. This can lead to loss of information, especially for tokens, which then degrades the sentence representation. We propose MEXMA, a novel approach that integrates both sentence-level and token-level objectives. The sentence representation in one language is used to predict masked tokens in another language, with both the sentence representation and all tokens directly updating the encoder. We show that adding token-level objectives greatly improves the sentence representation quality across several tasks. Our approach outperforms current pre-trained cross-lingual sentence encoders on bi-text mining as well as several downstream tasks. We also analyse the information encoded in our tokens, and how the sentence representation is built from them.
Usage
You use this model as you would any other XLM-RoBERTa model, taking into account that the "pooler" has not been trained, so you should use the CLS the encoder outputs directly as your sentence representation:
from transformers import AutoTokenizer, XLMRobertaModel
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-large")
model = XLMRobertaModel.from_pretrained("facebook/MEXMA", add_pooling_layer=False)
example_sentences = ['Sentence1', 'Sentence2']
example_inputs = tokenizer(example_sentences, return_tensors='pt')
outputs = model(**example_inputs)
sentence_representation = outputs.last_hidden_state[:, 0]
print(sentence_representation.shape) # torch.Size([2, 1024])
License
This model is released under the MIT license.
Training code
For the training code of this model, please check the official MEXMA repo.
Paper
MEXMA: Token-level objectives improve sentence representations
Citation
If you use this model in your work, please cite:
@misc{janeiro2024mexma,
title={MEXMA: Token-level objectives improve sentence representations},
author={João Maria Janeiro and Benjamin Piwowarski and Patrick Gallinari and Loïc Barrault},
year={2024},
eprint={2409.12737},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2409.12737},
}
- Downloads last month
- 574
Model tree for facebook/MEXMA
Base model
FacebookAI/xlm-roberta-large