language:
- lb license: cc-by-sa-4.0 library_name: transformers pipeline_tag: fill-mask tags:
- modernbert
- encoder
- luxembourgish
- multilingual
- masked-language-modeling
LUNI-mini
A ModernBERT-based masked language model pretrained on Luxembourgish (+ augmented Luxembourgish), following the Ettin recipe (see here: https://huggingface.co/jhu-clsp/ettin-encoder-68m)
Model Details
- Architecture: ModernBERT (encoder)
- Size: mini
- Vocabulary: 50,368 tokens (BPE, GPTNeoXTokenizerFast)
- Context length: 1,024 tokens
- Language: Luxembourgish (
lb/ltz) - License: CC BY-SA 4.0
Usage
Requires transformers>=4.48.0.
from transformers import AutoModelForMaskedLM, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("instilux/luni-mini")
model = AutoModelForMaskedLM.from_pretrained("instilux/luni-mini")
inputs = tokenizer("Wéi spéit [MASK] et?", return_tensors="pt")
mask_pos = (inputs["input_ids"] == tokenizer.mask_token_id).nonzero(as_tuple=True)[1]
with torch.no_grad():
outputs = model(**inputs)
top_tokens = outputs.logits[0, mask_pos].topk(5)
for token_id, score in zip(top_tokens.indices[0], top_tokens.values[0]):
token = tokenizer.decode(token_id)
print(f"{token:15s} {score:.3f}")
Tokenization and special tokens
Use the tokenizer as is. It reproduces the input format used in pretraining.
- No end-of-sequence token. The tokenizer prepends
[CLS]but does not append[SEP]: inputs are[CLS] tok_1 … tok_n. This matches pretraining.config.jsonlistseos_token_idandsep_token_idas 1 ([SEP]), but the model never saw[SEP]during pretraining, so we do not recommend adding it manually. - Sentence pairs. For two input texts, the tokenizer produces
[CLS] A [CLS] B, with a second[CLS]as separator and no[SEP]. Pretraining used single texts only (no sequence packing), so the model only learns this pair format during fine-tuning. - Pooling. The default for sequence classification is
classifier_pooling: "mean". All our reported fine-tuning results use this default. [CLS]input embedding. During pretraining, the embedding padding index was set to 0 ([CLS]) instead of 2 ([PAD]). As a result, the input embedding of[CLS]received no gradient from its role as an input token; it was updated only through the tied output layer. The released config uses the correctpad_token_id=2, so the[CLS]embedding is trained normally during fine-tuning. Users who need an untuned sentence representation from[CLS]should keep this in mind. With the default mean pooling it has little effect.
Citation
Paper coming soon!