nomic-ai/nomic-xlm-2048

Model

8

stars

10

commits

2

linked in READMEs

Feb 12, 2025

updated

custom_code
fill-mask
nomic_bert
safetensors
transformers

README

nomic-xlm-2048: XLM-Roberta Base with RoPE

nomic-xlm-2048 is a finetuned XLM-Roberta Base model with learned positional embeddings swapped for RoPE and trained for 10k steps on CC100.

nomic-xlm-2048 performs competitively to other multilingual encoders on GLUE and XTREME-R

ModelParamsPos.Seq.Avg.CoLASST-2MRPCSTS-BQQPMNLIQNLIRTE
XLM-R-Base279MAbs.51282.3546.9592.5487.3789.3290.6984.3490.3577.26
nomic-xlm-2048278MRoPE204881.6344.6991.9787.5088.4890.3883.5989.3876.54
mGTE-Base306MRoPE819280.7727.2291.9789.7189.5591.2085.1690.9180.41
ModelAvg.XNLIXCOPAUDPOSWikiANNXQuADMLQATyDiQA-GoldPMewsli-XLAReQATatoeba
XLM-R-Base62.3174.4951.874.3360.9972.9661.4554.3142.4563.4966.79
nomic-xlm-204862.7073.5761.7174.9260.9671.1359.6143.4645.2767.4970.82
mGTE-Base64.6373.5863.6273.5260.7274.7163.8849.6844.5871.9070.07

Usage

from transformers import AutoModelForMaskedLM, AutoConfig, AutoTokenizer, pipeline

tokenizer = AutoTokenizer.from_pretrained('nomic-ai/nomic-xlm-2048') # `nomic-bert-2048` uses the standard BERT tokenizer

config = AutoConfig.from_pretrained('nomic-ai/nomic-xlm-2048', trust_remote_code=True) # the config needs to be passed in
model = AutoModelForMaskedLM.from_pretrained('nomic-ai/nomic-xlm-2048',config=config, trust_remote_code=True)

# To use this model directly for masked language modeling
classifier = pipeline('fill-mask', model=model, tokenizer=tokenizer,device="cpu")

print(classifier("I [MASK] to the store yesterday."))

To finetune the model for a Sequence Classification task, you can use the following snippet

from transformers import AutoConfig, AutoModelForSequenceClassification
model_path = "nomic-ai/nomic-xlm-2048"
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
# strict needs to be false here since we're initializing some new params
model = AutoModelForSequenceClassification.from_pretrained(model_path, config=config, trust_remote_code=True, strict=False)

Join the Nomic Community

Contributors

zpn

10 commits

nomic-ai/nomic-xlm-2048

Model

8

stars

10

commits

2

linked in READMEs

Feb 12, 2025

updated

custom_code
fill-mask
nomic_bert
safetensors
transformers

README

nomic-xlm-2048: XLM-Roberta Base with RoPE

nomic-xlm-2048 is a finetuned XLM-Roberta Base model with learned positional embeddings swapped for RoPE and trained for 10k steps on CC100.

nomic-xlm-2048 performs competitively to other multilingual encoders on GLUE and XTREME-R

ModelParamsPos.Seq.Avg.CoLASST-2MRPCSTS-BQQPMNLIQNLIRTE
XLM-R-Base279MAbs.51282.3546.9592.5487.3789.3290.6984.3490.3577.26
nomic-xlm-2048278MRoPE204881.6344.6991.9787.5088.4890.3883.5989.3876.54
mGTE-Base306MRoPE819280.7727.2291.9789.7189.5591.2085.1690.9180.41
ModelAvg.XNLIXCOPAUDPOSWikiANNXQuADMLQATyDiQA-GoldPMewsli-XLAReQATatoeba
XLM-R-Base62.3174.4951.874.3360.9972.9661.4554.3142.4563.4966.79
nomic-xlm-204862.7073.5761.7174.9260.9671.1359.6143.4645.2767.4970.82
mGTE-Base64.6373.5863.6273.5260.7274.7163.8849.6844.5871.9070.07

Usage

from transformers import AutoModelForMaskedLM, AutoConfig, AutoTokenizer, pipeline

tokenizer = AutoTokenizer.from_pretrained('nomic-ai/nomic-xlm-2048') # `nomic-bert-2048` uses the standard BERT tokenizer

config = AutoConfig.from_pretrained('nomic-ai/nomic-xlm-2048', trust_remote_code=True) # the config needs to be passed in
model = AutoModelForMaskedLM.from_pretrained('nomic-ai/nomic-xlm-2048',config=config, trust_remote_code=True)

# To use this model directly for masked language modeling
classifier = pipeline('fill-mask', model=model, tokenizer=tokenizer,device="cpu")

print(classifier("I [MASK] to the store yesterday."))

To finetune the model for a Sequence Classification task, you can use the following snippet

from transformers import AutoConfig, AutoModelForSequenceClassification
model_path = "nomic-ai/nomic-xlm-2048"
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
# strict needs to be false here since we're initializing some new params
model = AutoModelForSequenceClassification.from_pretrained(model_path, config=config, trust_remote_code=True, strict=False)

Join the Nomic Community

Contributors

zpn

10 commits