Feature Extraction
sentence-transformers
Safetensors
English
xlm-roberta
splade
sparse-encoder
lexical-semantics
word-in-context
word-sense-disambiguation
text-embeddings-inference
Instructions to use jadermcs/lexsplade-xlm-roberta-large-silver with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use jadermcs/lexsplade-xlm-roberta-large-silver with sentence-transformers:
from sentence_transformers import SparseEncoder model = SparseEncoder("jadermcs/lexsplade-xlm-roberta-large-silver") queries = ["Which planet is known as the Red Planet?"] documents = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", ] query_embeddings = model.encode_query(queries) document_embeddings = model.encode_document(documents) similarities = model.similarity(query_embeddings, document_embeddings) print(similarities) - Notebooks
- Google Colab
- Kaggle
LexSPLADE (xlm-roberta-large, silver)
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.
Trained on English data only. It shares its base with XL-LEXEME
(pierluigic/xl-lexeme), so the two can be compared on the same backbone.
Usage
from sentence_transformers import SparseEncoder
import torch
model = SparseEncoder("jadermcs/lexsplade-xlm-roberta-large-silver", trust_remote_code=True)
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.08
# Read a vector as words
top = v[1].topk(8).indices
print([model.tokenizer.convert_ids_to_tokens(int(i)) for i in top])
# ['▁bank', '▁home', '▁account', '▁checking', '▁deposit', '▁banc', '▁online', '▁card']
- Wrap the target in
<t>…</t>;<t>bank</t>is the form used in training. trust_remote_code=Trueis 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 asmodeling_lexsplade.py. Running the MLM head on the span alone also avoids a[batch, seq, 250k]logit tensor.- Keep the marked word inside
max_seq_length. If the markers are truncated away, the pooling falls back to the whole sentence and returns a sentence embedding.
Training
| base model | FacebookAI/xlm-roberta-large |
| training data | 31,914 same-lemma word-in-context pairs (LLM-verified silver + MCL-WiC train) |
| 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; XLM-R's raw logits sit far above zero) |
| masked outputs | special tokens, stop words and tokens without a letter or digit |
| seed | 44 |
Evaluation
MCL-WiC, English. AP is average precision of the cosine similarity; accuracy is at the best threshold on that split.
| split | accuracy | AP |
|---|---|---|
| test | 91.70 | 96.67 |
| dev | 91.00 | 95.07 |
Mean nonzero dimensions per usage on MCL-WiC test: 246 of 250,004.
Variants
jadermcs/lexsplade-bert-large-silver: BERT-large, silver only.jadermcs/lexsplade-roberta-large-silver-wic-wnbags: RoBERTa-large, silver + WiC, with WordNet sense bags.
- Downloads last month
- 14
Model tree for jadermcs/lexsplade-xlm-roberta-large-silver
Base model
FacebookAI/xlm-roberta-large