Downloads · 30 days
40
11% of all-time downloads
eliasjacob/ModernBERT-large-portuguese
ModernBERT-large-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
40
11% of all-time downloads
All-time downloads
368
Public
Parameters
396M
3.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.6 GB · 100%
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 V2 dataset. I've followed the exact same training recipe as in the original paper.
import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "eliasjacob/ModernBERT-large-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