SentenceTransformer based on wallacelw/ModBERTBr
This is a sentence-transformers model finetuned from wallacelw/ModBERTBr on the nli_pt_anli, nli_pt_fever, nli_pt_ling, nli_pt_mnli, nli_pt_wanli, stsb, assin1, assin2, IRIS_sts, sick_br and mldr datasets. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: wallacelw/ModBERTBr
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Datasets:
- Languages: multilingual, zh, ja, ar, ko, de, fr, es, pt, hi, id, it, tr, ru, bn, ur, mr, ta, vi, fa, pl, uk, nl, sv, he, sw, ps, en, th
Model Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'ModernBertModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("iara-project/ModBERTBr-sts-pt")
sentences = [
'Uma menina jovem está usando língua de sinais',
'Língua de sinais está sendo usada por uma jovem menina',
'A mulher está fatiando um tomate',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities)
Evaluation
Metrics
Semantic Similarity
- Datasets:
stsb-pt-dev-768, assin2-dev-768, iris_sts-dev-768 and sick_br_dev-768
- Evaluated with
EmbeddingSimilarityEvaluator with these parameters:{
"truncate_dim": 768
}
| Metric |
stsb-pt-dev-768 |
assin2-dev-768 |
iris_sts-dev-768 |
sick_br_dev-768 |
| pearson_cosine |
0.8418 |
0.9705 |
0.8079 |
0.8577 |
| spearman_cosine |
0.8419 |
0.9717 |
0.799 |
0.8377 |
Semantic Similarity
- Datasets:
stsb-pt-dev-512, assin2-dev-512, iris_sts-dev-512 and sick_br_dev-512
- Evaluated with
EmbeddingSimilarityEvaluator with these parameters:{
"truncate_dim": 512
}
| Metric |
stsb-pt-dev-512 |
assin2-dev-512 |
iris_sts-dev-512 |
sick_br_dev-512 |
| pearson_cosine |
0.8387 |
0.9666 |
0.8086 |
0.8516 |
| spearman_cosine |
0.8393 |
0.9692 |
0.8016 |
0.8332 |
Semantic Similarity
- Datasets:
stsb-pt-dev-256, assin2-dev-256, iris_sts-dev-256 and sick_br_dev-256
- Evaluated with
EmbeddingSimilarityEvaluator with these parameters:{
"truncate_dim": 256
}
| Metric |
stsb-pt-dev-256 |
assin2-dev-256 |
iris_sts-dev-256 |
sick_br_dev-256 |
| pearson_cosine |
0.8315 |
0.9599 |
0.802 |
0.8388 |
| spearman_cosine |
0.8337 |
0.9639 |
0.8008 |
0.8236 |
Semantic Similarity
- Datasets:
stsb-pt-dev-128, assin2-dev-128, iris_sts-dev-128 and sick_br_dev-128
- Evaluated with
EmbeddingSimilarityEvaluator with these parameters:{
"truncate_dim": 128
}
| Metric |
stsb-pt-dev-128 |
assin2-dev-128 |
iris_sts-dev-128 |
sick_br_dev-128 |
| pearson_cosine |
0.8177 |
0.9453 |
0.7751 |
0.813 |
| spearman_cosine |
0.822 |
0.9552 |
0.7848 |
0.8041 |
Semantic Similarity
- Datasets:
stsb-pt-dev-64, assin2-dev-64, iris_sts-dev-64 and sick_br_dev-64
- Evaluated with
EmbeddingSimilarityEvaluator with these parameters:{
"truncate_dim": 64
}
| Metric |
stsb-pt-dev-64 |
assin2-dev-64 |
iris_sts-dev-64 |
sick_br_dev-64 |
| pearson_cosine |
0.7786 |
0.9173 |
0.7269 |
0.7591 |
| spearman_cosine |
0.7899 |
0.9393 |
0.7467 |
0.7583 |
Training Details
Training Datasets
nli_pt_anli
nli_pt_anli
nli_pt_fever
nli_pt_fever
nli_pt_ling
nli_pt_ling
nli_pt_mnli
nli_pt_mnli
nli_pt_wanli
nli_pt_wanli
stsb
stsb
assin1
assin1
assin2
assin2
IRIS_sts
IRIS_sts
sick_br
sick_br
mldr
mldr
Evaluation Datasets
stsb
stsb
assin2
assin2
IRIS_sts
IRIS_sts
sick_br
sick_br
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: steps
per_device_train_batch_size: 64
gradient_accumulation_steps: 4
weight_decay: 0.2
num_train_epochs: 20
warmup_steps: 0.1
fp16: True
gradient_checkpointing: True
gradient_checkpointing_kwargs: {'use_reentrant': False}
All Hyperparameters
Click to expand
do_predict: False
eval_strategy: steps
prediction_loss_only: True
per_device_train_batch_size: 64
per_device_eval_batch_size: 8
gradient_accumulation_steps: 4
eval_accumulation_steps: None
torch_empty_cache_steps: None
learning_rate: 5e-05
weight_decay: 0.2
adam_beta1: 0.9
adam_beta2: 0.999
adam_epsilon: 1e-08
max_grad_norm: 1.0
num_train_epochs: 20
max_steps: -1
lr_scheduler_type: linear
lr_scheduler_kwargs: None
warmup_ratio: None
warmup_steps: 0.1
log_level: passive
log_level_replica: warning
log_on_each_node: True
logging_nan_inf_filter: True
enable_jit_checkpoint: False
save_on_each_node: False
save_only_model: False
restore_callback_states_from_checkpoint: False
use_cpu: False
seed: 42
data_seed: None
bf16: False
fp16: True
bf16_full_eval: False
fp16_full_eval: False
tf32: None
local_rank: -1
ddp_backend: None
debug: []
dataloader_drop_last: True
dataloader_num_workers: 0
dataloader_prefetch_factor: None
disable_tqdm: False
remove_unused_columns: True
label_names: None
load_best_model_at_end: False
ignore_data_skip: False
fsdp: []
fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
parallelism_config: None
deepspeed: None
label_smoothing_factor: 0.0
optim: adamw_torch_fused
optim_args: None
group_by_length: False
length_column_name: length
project: huggingface
trackio_space_id: trackio
ddp_find_unused_parameters: None
ddp_bucket_cap_mb: None
ddp_broadcast_buffers: False
dataloader_pin_memory: True
dataloader_persistent_workers: False
skip_memory_metrics: True
push_to_hub: False
resume_from_checkpoint: None
hub_model_id: None
hub_strategy: every_save
hub_private_repo: None
hub_always_push: False
hub_revision: None
gradient_checkpointing: True
gradient_checkpointing_kwargs: {'use_reentrant': False}
include_for_metrics: []
eval_do_concat_batches: True
auto_find_batch_size: False
full_determinism: False
ddp_timeout: 1800
torch_compile: False
torch_compile_backend: None
torch_compile_mode: None
include_num_input_tokens_seen: no
neftune_noise_alpha: None
optim_target_modules: None
batch_eval_metrics: False
eval_on_start: False
use_liger_kernel: False
liger_kernel_config: None
eval_use_gather_object: False
average_tokens_across_devices: True
use_cache: False
prompts: None
batch_sampler: batch_sampler
multi_dataset_batch_sampler: proportional
router_mapping: {}
learning_rate_mapping: {}
Training Logs
| Epoch |
Step |
Training Loss |
stsb loss |
assin2 loss |
IRIS sts loss |
sick br loss |
stsb-pt-dev-768_spearman_cosine |
assin2-dev-768_spearman_cosine |
iris_sts-dev-768_spearman_cosine |
sick_br_dev-768_spearman_cosine |
stsb-pt-dev-512_spearman_cosine |
assin2-dev-512_spearman_cosine |
iris_sts-dev-512_spearman_cosine |
sick_br_dev-512_spearman_cosine |
stsb-pt-dev-256_spearman_cosine |
assin2-dev-256_spearman_cosine |
iris_sts-dev-256_spearman_cosine |
sick_br_dev-256_spearman_cosine |
stsb-pt-dev-128_spearman_cosine |
assin2-dev-128_spearman_cosine |
iris_sts-dev-128_spearman_cosine |
sick_br_dev-128_spearman_cosine |
stsb-pt-dev-64_spearman_cosine |
assin2-dev-64_spearman_cosine |
iris_sts-dev-64_spearman_cosine |
sick_br_dev-64_spearman_cosine |
| 0.7663 |
100 |
3.6306 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 1.5287 |
200 |
2.8394 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 1.9119 |
250 |
- |
3.9274 |
2.7242 |
3.4710 |
2.8596 |
0.7930 |
0.8658 |
0.7612 |
0.8176 |
0.7823 |
0.8651 |
0.7599 |
0.8148 |
0.7678 |
0.8584 |
0.7456 |
0.8118 |
0.7429 |
0.8534 |
0.7285 |
0.8036 |
0.7225 |
0.8391 |
0.7191 |
0.7872 |
| 2.2912 |
300 |
2.5801 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 3.0536 |
400 |
2.5148 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 3.8199 |
500 |
2.4273 |
4.5505 |
2.5652 |
3.4786 |
2.9762 |
0.7758 |
0.8967 |
0.7586 |
0.8120 |
0.7640 |
0.8956 |
0.7546 |
0.8102 |
0.7447 |
0.8943 |
0.7417 |
0.8075 |
0.7130 |
0.8892 |
0.7235 |
0.8035 |
0.6891 |
0.8835 |
0.7103 |
0.7942 |
| 4.5824 |
600 |
2.4090 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 5.3448 |
700 |
2.3683 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 5.7280 |
750 |
- |
3.8926 |
2.3960 |
3.4898 |
2.9594 |
0.8198 |
0.9288 |
0.7808 |
0.8344 |
0.8140 |
0.9267 |
0.7821 |
0.8299 |
0.8054 |
0.9223 |
0.7752 |
0.8222 |
0.7864 |
0.9132 |
0.7649 |
0.8098 |
0.7636 |
0.9034 |
0.7486 |
0.7906 |
| 6.1073 |
800 |
2.3605 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 6.8736 |
900 |
2.3193 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 7.6360 |
1000 |
2.2318 |
4.4184 |
2.3248 |
3.8951 |
3.1203 |
0.8129 |
0.9304 |
0.7806 |
0.8407 |
0.8029 |
0.9292 |
0.7801 |
0.8370 |
0.7864 |
0.9234 |
0.7717 |
0.8300 |
0.7577 |
0.9180 |
0.7512 |
0.8171 |
0.7224 |
0.9085 |
0.7239 |
0.7902 |
| 8.3985 |
1100 |
2.2238 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 9.1609 |
1200 |
2.2415 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 9.5441 |
1250 |
- |
4.4970 |
2.2180 |
4.3361 |
3.2464 |
0.8218 |
0.9445 |
0.7932 |
0.8437 |
0.8146 |
0.9416 |
0.7935 |
0.8391 |
0.8014 |
0.9368 |
0.7910 |
0.8327 |
0.7754 |
0.9283 |
0.7742 |
0.8186 |
0.7347 |
0.9146 |
0.7398 |
0.7915 |
| 9.9272 |
1300 |
2.2028 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 10.6897 |
1400 |
2.1467 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 11.4521 |
1500 |
2.0469 |
4.5380 |
2.1063 |
4.3540 |
3.6844 |
0.8299 |
0.9522 |
0.7844 |
0.8383 |
0.8239 |
0.9512 |
0.7840 |
0.8346 |
0.8155 |
0.9469 |
0.7776 |
0.8288 |
0.7905 |
0.9367 |
0.7450 |
0.8102 |
0.7454 |
0.9211 |
0.7082 |
0.7723 |
| 12.2146 |
1600 |
2.0805 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 12.9808 |
1700 |
2.0895 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 13.3602 |
1750 |
- |
4.6506 |
2.1541 |
4.8472 |
3.9376 |
0.8390 |
0.9588 |
0.7887 |
0.8376 |
0.8341 |
0.9568 |
0.7910 |
0.8348 |
0.8249 |
0.9501 |
0.7902 |
0.8253 |
0.8021 |
0.9395 |
0.7667 |
0.8048 |
0.7540 |
0.9195 |
0.7219 |
0.7639 |
| 13.7433 |
1800 |
2.0056 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 14.5057 |
1900 |
1.9248 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 15.2682 |
2000 |
1.9185 |
4.8262 |
2.1039 |
5.1240 |
4.4055 |
0.8421 |
0.9633 |
0.7995 |
0.8312 |
0.8388 |
0.9614 |
0.7998 |
0.8275 |
0.8321 |
0.9573 |
0.7969 |
0.8199 |
0.8148 |
0.9457 |
0.7729 |
0.7995 |
0.7725 |
0.9261 |
0.7237 |
0.7510 |
| 16.0307 |
2100 |
1.8993 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 16.7969 |
2200 |
1.8331 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 17.1762 |
2250 |
- |
4.9829 |
1.9275 |
5.5086 |
4.8501 |
0.8434 |
0.9689 |
0.7996 |
0.8353 |
0.8408 |
0.9666 |
0.8015 |
0.8312 |
0.8353 |
0.9619 |
0.8005 |
0.8220 |
0.8228 |
0.9521 |
0.7824 |
0.8027 |
0.7873 |
0.9336 |
0.7387 |
0.7506 |
| 17.5594 |
2300 |
1.7637 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 18.3218 |
2400 |
1.7584 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
| 19.0843 |
2500 |
1.7560 |
5.0568 |
1.9085 |
5.6523 |
5.0540 |
0.8419 |
0.9717 |
0.7990 |
0.8377 |
0.8393 |
0.9692 |
0.8016 |
0.8332 |
0.8337 |
0.9639 |
0.8008 |
0.8236 |
0.8220 |
0.9552 |
0.7848 |
0.8041 |
0.7899 |
0.9393 |
0.7467 |
0.7583 |
| 19.8506 |
2600 |
1.6983 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
Framework Versions
- Python: 3.12.12
- Sentence Transformers: 5.2.3
- Transformers: 5.0.0
- PyTorch: 2.10.0+cu128
- Accelerate: 1.12.0
- Datasets: 4.8.3
- Tokenizers: 0.22.2
Citation
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
CoSENTLoss
@article{10531646,
author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
year={2024},
doi={10.1109/TASLP.2024.3402087}
}