Downloads · 30 days
38
4% of all-time downloads
eliasjacob/ModernBERT-base-portuguese
ModernBERT-base-portuguese is a fill-mask model from eliasjacob. Use it when you need the model to fill a missing word. It is set up for transformers.
This model and its tokenizer were fully pretrained on Portuguese text. I don't have time right now to write more about the training process. Contact me at elias.jacob at ufrn.br if you need some info before I have the…
Downloads · 30 days
38
4% of all-time downloads
All-time downloads
883
Public
Parameters
150M
1.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors598 MB · 99%
From the Hugging Face model README
This model and its tokenizer were fully pretrained on Portuguese text. I don't have time right now to write more about the training process. Contact me at elias.jacob at ufrn.br if you need some info before I have the time to publish something more detailed. The training data was the cleaned Portuguese subset of the HPLT V3 dataset. I've followed the almost the same training recipe as in the original paper, but training longer (2_000_000_000_000 tokens during pretraining + 300_000_000_000 tokens during context extension + 70_000_000_000 tokens during the learning rate decay phase)
import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "eliasjacob/ModernBERT-base-portuguese"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
device = torch.device("cpu")
model.to(device)
text = "O código penal brasileiro estabelece, em seu artigo [MASK], o crime de homicídio"
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
# To get predictions for the mask:
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs.logits[0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print("Predicted token:", predicted_token)
Predicted token: 121