Downloads · 30 days
685
40% of all-time downloads
unb-labia/BERTomelo-ModernBERT-Large-v1
BERTomelo-ModernBERT-Large-v1 is a machine learning model from unb-labia. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
BERTomelo is a variant of BERT encoders built upon the ModernBERT architecture. It is pretrained from scratch on the Classified Common Crawl Corpus for Portuguese (ClassiCC PT), specifically tailored and specialized f…
Downloads · 30 days
685
40% of all-time downloads
All-time downloads
1.7K
Public
Parameters
378M
1.5 GB on disk
Likes
4
Public
Click a slice to open those files.
.safetensors1.5 GB · 100%
From the Hugging Face model README
BERTomelo is a variant of BERT encoders built upon the ModernBERT architecture. It is pretrained from scratch on the Classified Common Crawl Corpus for Portuguese (ClassiCC PT), specifically tailored and specialized for the Portuguese language. BERTomelo try to fill the gap of older Brazilian BERT models with the native long context capability, making it ideal for tasks that require processing extensive documents, mirroring the efficiency of the ModernBERT reference architecture.
BERTomelo leverages several recent advancements in transformer design integrated into the ModernBERT architecture, such as:
The pretraining of BERTomelo encompasses 386.48 billion tokens. The custom tokenizer is sourced from ModBERTBr, trained using a Unigram algorithm on the BrWaC corpus and the Wikipedia Portuguese dataset.
| Model Variant | Layers | Parameters | Context Window |
|---|---|---|---|
| BERTomelo Base | 22 | 136 Million | 1,024 tokens |
| BERTomelo Large | 28 | 377 Million | 1,024 tokens |
You can use BERTomelo leveraging the transformers library since version v4.48.0:
pip install -U transformers>=4.48.0
Since BERTomelo is pretrained using a Masked Language Model (MLM) objective, it can be used directly for inference via AutoModelForMaskedLM or the fill-mask pipeline. It also serves as a robust backbone for fine tuning on downstream tasks such as classification, textual similarity, retrieval, or question answering.
⚠️ Note: We recommend using FlashAttention 2 to achieve the highest processing efficiency and throughput.
Using AutoModelForMaskedLM:
from transformers import AutoTokenizer, AutoModelForMaskedLM
model_id = "unb-labia/BERTomelo-ModernBERT-Large-v1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForMaskedLM.from_pretrained(model_id)
text = "O cachorro mais famoso do brasil é o vira [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
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)
Using a pipeline:
import torch
from transformers import pipeline
from pprint import pprint
pipe = pipeline(
"fill-mask",
model="unb-labia/BERTomelo-ModernBERT-Large-v1",
)
input_text = "O Brasil está presente na [MASK] do sul."
results = pipe(input_text)
for result in results:
print(f"Token: {result['token_str']} | Score: {result['score']:.4f}")
Note: Unlike traditional BERT models, the ModernBERT architecture utilized by BERTomelo does not require token type IDs. You can omit this parameter in most downstream tasks.
The following table summarizes the performance of BERTomelo compared to other prominent models for Brazilian Portuguese across Semantic Textual Similarity (STS), Recognizing Textual Entailment (RTE), and Named Entity Recognition (NER).
<!-- | Model | STS MSE ↓ | STS Pearson ↑ | RTE F1 ↑ | RTE Acc ↑ | NER F1 ↑ | NER Recall ↑ | NER Prec ↑ | | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | mBERT | 0.597 | 0.801 | 84.45% | 84.52% | 88.50% | 90.45% | 86.63% | | BERTimbau | 0.580 | 0.836 | 89.20% | 89.20% | 90.48% | 91.64% | 89.35% | | BERTuguês | 0.583 | 0.823 | 86.27% | 86.40% | 89.56% | 90.59% | 88.55% | | ModernBERT | 0.514 | 0.790 | 81.09% | 81.17% | 75.76% | 78.03% | 73.61% | | ModBERTBr | 0.509 | 0.812 | 85.28% | 85.42% | 90.08% | **92.40%** | 87.88% | | **BERTomelo Base** | **0.425** | 0.833 | 87.65% | 87.70% | **91.37%** | 92.29% | **90.46%** | | BERTimbau Large | 0.500 | 0.852 | **90.04%** | **90.04%** | 90.54% | 92.24% | 88.90% | | Albertina 900M | 0.570 | **0.853** | 89.09% | 89.09% | 87.28% | 91.43% | 83.49% | | **BERTomelo Large** | **0.401** | 0.849 | 89.21% | 89.26% | **91.05%** | **92.75%** | **89.42%** | -->Our evaluation pipeline is designed to ensure statistical robustness by separating hyperparameter tuning from the final multi-seed evaluation.
load_best_model_at_end=True, the model always reverts to the weights that achieved the highest validation score, regardless of when training halted.Aggregated results (Mean ± Standard Deviation) by model and benchmark.
| Model | Pearson ↑<br>(ASSIN 2) | MSE ↓<br>(ASSIN 2) | Macro F1 ↑<br>(ASSIN 2) | Accuracy ↑<br>(ASSIN 2) | F1 ↑<br>(LENER-BR) | Precision ↑<br>(LENER-BR) | Recall ↑<br>(LENER-BR) |
|---|---|---|---|---|---|---|---|
| Base Models | |||||||
| mBERT | 0.8171 ± 0.0057 | 0.5576 ± 0.0126 | 0.8667 ± 0.0074 | 0.8672 ± 0.0073 | 0.8614 ± 0.0045 | 0.8417 ± 0.0094 | 0.8823 ± 0.0085 |
| BERTimbau | 0.8345 ± 0.0035 | 0.5723 ± 0.0199 | 0.8851 ± 0.0065 | 0.8855 ± 0.0063 | 0.8892 ± 0.0085 | 0.8667 ± 0.0123 | 0.9130 ± 0.0058 |
| BERTuguês | 0.8352 ± 0.0044 | 0.5694 ± 0.0222 | 0.8775 ± 0.0053 | 0.8781 ± 0.0053 | 0.8745 ± 0.0095 | 0.8576 ± 0.0122 | 0.8922 ± 0.0083 |
| ModernBERT | 0.7730 ± 0.0072 | 0.5643 ± 0.0208 | 0.8174 ± 0.0086 | 0.8184 ± 0.0083 | 0.7575 ± 0.0113 | 0.7292 ± 0.0154 | 0.7883 ± 0.0081 |
| ModBERTBr | 0.8065 ± 0.0026 | 0.5283 ± 0.0094 | 0.8336 ± 0.0090 | 0.8354 ± 0.0087 | 0.8916 ± 0.0083 | 0.8763 ± 0.0107 | 0.9075 ± 0.0070 |
| BERTomelo-Base | 0.8375 ± 0.0019 | 0.4570 ± 0.0077 | 0.8693 ± 0.0144 | 0.8701 ± 0.0139 | 0.8987 ± 0.0104 | 0.8845 ± 0.0152 | 0.9135 ± 0.0073 |
| modernJabuticaBERT-Base-1k | 0.8507 ± 0.0033 | 0.4468 ± 0.0801 | 0.8678 ± 0.0087 | 0.8683 ± 0.0085 | 0.8503 ± 0.0068 | 0.8280 ± 0.0093 | 0.8738 ± 0.0057 |
| modernJabuticaBERT-Base-8k | 0.8460 ± 0.0032 | 0.4167 ± 0.0063 | 0.8820 ± 0.0027 | 0.8824 ± 0.0027 | 0.8685 ± 0.0092 | 0.8444 ± 0.0150 | 0.8940 ± 0.0059 |
| NorBERTo-Base | 0.8544 ± 0.0023 | 0.4086 ± 0.0056 | 0.8918 ± 0.0060 | 0.8922 ± 0.0061 | 0.8545 ± 0.0128 | 0.8356 ± 0.0199 | 0.8743 ± 0.0086 |
| Large Models | |||||||
| ModernBERT-Large | 0.8107 ± 0.0052 | 0.4792 ± 0.0131 | 0.8525 ± 0.0109 | 0.8532 ± 0.0105 | 0.7921 ± 0.0181 | 0.7721 ± 0.0295 | 0.8136 ± 0.0097 |
| BERTomelo-Large | 0.8577 ± 0.0012 | 0.4078 ± 0.0075 | 0.8857 ± 0.0085 | 0.8860 ± 0.0084 | 0.8917 ± 0.0047 | 0.8755 ± 0.0070 | 0.9084 ± 0.0080 |
| modernJabuticaBERT-Large-1k | 0.8585 ± 0.0032 | 0.3994 ± 0.0055 | 0.8879 ± 0.0079 | 0.8884 ± 0.0078 | 0.8697 ± 0.0156 | 0.8461 ± 0.0173 | 0.8947 ± 0.0162 |
| modernJabuticaBERT-Large-8k | 0.8576 ± 0.0024 | 0.3981 ± 0.0082 | 0.8988 ± 0.0049 | 0.8991 ± 0.0048 | 0.8846 ± 0.0158 | 0.8656 ± 0.0235 | 0.9046 ± 0.0094 |
| NorBERTo-Large | 0.8506 ± 0.0021 | 0.4120 ± 0.0071 | 0.8916 ± 0.0105 | 0.8920 ± 0.0104 | 0.8743 ± 0.0120 | 0.8550 ± 0.0227 | 0.8949 ± 0.0075 |
This work was supported in part by Advanced Micro Devices, Inc. under the AMD AI & HPC Cluster Program. Furthermore, the respective authors are appreciated for providing the ClassiCC-PT, ASSIN2, and LeNER-BR datasets, as well as the developers of ModBERTBr for their foundational work in adapting this architecture for the Brazilian Portuguese language.