LUNI
Collection
Diversity Matters: Encoder Models trained with augmented data • 3 items • Updated
How to use instilux/luni-mini with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("fill-mask", model="instilux/luni-mini") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained("instilux/luni-mini")
model = AutoModelForMaskedLM.from_pretrained("instilux/luni-mini", device_map="auto")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)
lb/ltz)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}")
Use the tokenizer as is. It reproduces the input format used in pretraining.
[CLS] but does not append
[SEP]: inputs are [CLS] tok_1 … tok_n. This matches pretraining. config.json
lists eos_token_id and sep_token_id as 1 ([SEP]), but the model never saw
[SEP] during pretraining, so we do not recommend adding it manually.[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.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 correct
pad_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.Paper coming soon!