A sparse contextual word encoder. Given a sentence with one word marked, it returns a sparse vector over XLM-R's 250,004-token vocabulary describing that word in that context: a word embedding, not a sentence embedding. Because the dimensions are vocabulary entries, a vector can be read directly as a list of words.
This is the multilingual LexSPLADE checkpoint: jadermcs/lexsplade-xlm-roberta-xl-silver
continued on a cleaned, language-balanced multilingual set. It matches that
model on English and is better on every multilingual set, by 5.9 AP on
cross-lingual MCL-WiC pairs.
from sentence_transformers import SparseEncoder
import torch
model = SparseEncoder(
"jadermcs/lexsplade-xlm-roberta-xl-silver-xllexeme",
trust_remote_code=True,
model_kwargs={"dtype": torch.bfloat16}, # 3.5B parameters: ~7 GB in bf16
)
sents = [
"He sat on the <t>bank</t> of the river and watched the water.",
"She withdrew the money from her <t>bank</t> on Monday morning.",
]
v = model.encode(sents, convert_to_tensor=True).to_dense().float()
print(torch.nn.functional.cosine_similarity(v[0:1], v[1:2], dim=1)) # ~0.06
# Read a vector as words
top = v[1].topk(8).indices
print([model.tokenizer.convert_ids_to_tokens(int(i)) for i in top])
# ['▁checking', '▁account', '▁bank', '▁cash', '▁loan', '▁Bank', '▁banko', '▁money']
<t> … </t>; <t>bank</t> is the form used in training.
The markers work the same in any language.trust_remote_code=True is required: the target-span pooling, which applies
the MLM head only to the marked tokens and centres the logits, is a custom
module shipped in this repo as modeling_lexsplade.py. Running the MLM head
on the span alone also avoids a [batch, seq, 250k] logit tensor.max_seq_length. If the markers are truncated
away, the pooling falls back to the whole sentence and returns a sentence
embedding.Two stages: stage 1 is jadermcs/lexsplade-xlm-roberta-xl-silver's recipe
(seed 43 of that recipe; the published silver checkpoint is seed 42); stage 2
continues it with a fresh LoRA adapter.
| base model | facebook/xlm-roberta-xl (3.5B) |
| stage 1 | LoRA r = 16, lr 2e-4, on 31,914 English same-lemma word-in-context pairs (LLM-verified silver + MCL-WiC train) |
| stage 2 | LoRA r = 16, lr 5e-5, up to 6 epochs (best at epoch 4), on stage 1's data + 15,244 pairs of cleaned XL-LEXEME training data |
| stage 2 data | 23 languages, 10,012 cross-lingual pairs; from AM²iCo (10,012), XL-WiC train/dev (4,232) and WiC train/dev (1,000), filtered by a stage-1 checkpoint's score and balanced by language |
| both stages | base in bf16; marker embeddings and MLM head trained in full; adapters merged into this checkpoint |
| objective | AnglE loss on the sparse target-word vectors, SPLADE FLOPS regularizer (1e-3), Barlow Twins term on the dense span representation |
| logit centring | z = 2.5 (per token, subtract mean + 2.5·std of the logits before the relu) |
| masked outputs | special tokens, stop words (English list) and tokens without a letter or digit |
| seed | 43 |
AP is average precision of the cosine similarity; accuracy figures are omitted because they are fit on the evaluated split. No test split below is in the training data; XL-WiC train and dev are.
| set | AP |
|---|---|
| MCL-WiC test (en-en) | 97.63 |
| MCL-WiC dev (en-en) | 96.70 |
| crosslemma dev | 95.43 |
| MCL-WiC test, same-language (ar / fr / ru / zh) | 93.18 / 94.80 / 93.58 / 91.98 |
| MCL-WiC test, cross-lingual (en-ar / en-fr / en-ru / en-zh) | 93.71 / 93.27 / 93.96 / 93.76 |
| XL-WiC test, mean of 12 languages | 79.32 |
XL-WiC test by language: bg 77.81, da 84.72, de 74.67, et 75.99, fa 94.90, fr 74.45, hr 76.43, it 74.38, ja 71.43, ko 77.46, nl 83.38, zh 86.26.
Over three seeds (42, 43, 44) the same recipe gives:
| this recipe | -xl-silver (stage 1 only) |
|
|---|---|---|
| MCL-WiC test (en) | 97.58 ± 0.12 | 97.55 ± 0.35 |
| MCL-WiC cross-lingual, mean of 4 pairs | 93.28 ± 0.65 | 87.35 ± 2.75 |
| XL-WiC test, mean of 12 languages | 78.89 ± 0.43 | 77.03 ± 0.49 |
This seed is the best of the three on cross-lingual MCL-WiC and XL-WiC and within 0.04 of the best on English test.
Mean nonzero dimensions per usage on MCL-WiC test (en): 219 of 250,004.
jadermcs/lexsplade-xlm-roberta-xl-silver: stage 1 only, English data.jadermcs/lexsplade-xlm-roberta-xl-silver-ldv: stage 1 with outputs restricted to the Longman defining vocabulary.jadermcs/lexsplade-xlm-roberta-large-silver: XLM-R-large, English data.jadermcs/lexsplade-roberta-large-silver-wic-wnbags: RoBERTa-large.jadermcs/lexsplade-bert-large-silver: BERT-large.facebook/xlm-roberta-xl