SentenceTransformer based on artiwise-ai/modernbert-base-tr-uncased
This is a sentence-transformers model finetuned from artiwise-ai/modernbert-base-tr-uncased on the all-nli-tr dataset. 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: artiwise-ai/modernbert-base-tr-uncased
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- Language: tr
Model Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: 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
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'Ve gerçekten, baba haklıydı, oğlu zaten her şeyi tecrübe etmişti, her şeyi denedi ve daha az ilgileniyordu.',
'Oğlu her şeye olan ilgisini kaybediyordu.',
'Baba oğlunun tecrübe için hala çok şey olduğunu biliyordu.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Semantic Similarity
| Metric | sts-dev | sts-test | sts22-test |
|---|
| pearson_cosine | 0.8317 | 0.8034 | 0.482 |
| spearman_cosine | 0.8335 | 0.8081 | 0.534 |
Triplet
| Metric | Value |
|---|
| cosine_accuracy | 0.9403 |
Semantic Similarity
| Metric | stsb-dev-768 | stsb-test-768 |
|---|
| pearson_cosine | 0.8505 | 0.8252 |
| spearman_cosine | 0.8546 | 0.8327 |
Semantic Similarity
| Metric | stsb-dev-512 | stsb-test-512 |
|---|
| pearson_cosine | 0.8517 | 0.8258 |
| spearman_cosine | 0.8557 | 0.8334 |
Semantic Similarity
| Metric | stsb-dev-256 | stsb-test-256 |
|---|
| pearson_cosine | 0.847 | 0.8211 |
| spearman_cosine | 0.8521 | 0.8315 |
Semantic Similarity
| Metric | stsb-dev-128 | stsb-test-128 |
|---|
| pearson_cosine | 0.838 | 0.8132 |
| spearman_cosine | 0.8463 | 0.8267 |
Semantic Similarity
| Metric | stsb-dev-64 | stsb-test-64 |
|---|
| pearson_cosine | 0.8274 | 0.7981 |
| spearman_cosine | 0.8399 | 0.8155 |
Training Details
Training Dataset
all-nli-tr
- Dataset: all-nli-tr at daeabfb
- Size: 5,749 training samples
- Columns: sentence1, sentence2, and score
- Approximate statistics based on the first 1000 samples:
| sentence1 | sentence2 | score |
|---|
| type | string | string | float |
| details | min: 5 tokensmean: 8.87 tokensmax: 25 tokens | min: 5 tokensmean: 8.9 tokensmax: 24 tokens | min: 0.0mean: 2.23max: 5.0 |
- Samples:
| sentence1 | sentence2 | score |
|---|
| Bir uçak kalkıyor. | Bir hava uçağı kalkıyor. | 5.0 |
| Bir adam büyük bir flüt çalıyor. | Bir adam flüt çalıyor. | 3.8 |
| Bir adam pizzaya rendelenmiş peynir yayıyor. | Bir adam pişmemiş pizzaya rendelenmiş peynir yayıyor. | 3.8 |
- Loss: MatryoshkaLoss with these parameters:
{
"loss": "CoSENTLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
Evaluation Dataset
all-nli-tr
- Dataset: all-nli-tr at daeabfb
- Size: 1,500 evaluation samples
- Columns: sentence1, sentence2, and score
- Approximate statistics based on the first 1000 samples:
| sentence1 | sentence2 | score |
|---|
| type | string | string | float |
| details | min: 5 tokensmean: 13.39 tokensmax: 39 tokens | min: 5 tokensmean: 13.5 tokensmax: 53 tokens | min: 0.0mean: 2.1max: 5.0 |
- Samples:
| sentence1 | sentence2 | score |
|---|
| Şapkalı bir adam dans ediyor. | Sert şapka takan bir adam dans ediyor. | 5.0 |
| Küçük bir çocuk ata biniyor. | Bir çocuk ata biniyor. | 4.75 |
| Bir adam yılana fare yediriyor. | Adam yılana fare yediriyor. | 5.0 |
- Loss: MatryoshkaLoss with these parameters:
{
"loss": "CoSENTLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: steps
per_device_train_batch_size: 32
per_device_eval_batch_size: 32
learning_rate: 1e-05
weight_decay: 0.01
num_train_epochs: 10
warmup_ratio: 0.1
warmup_steps: 144
bf16: True
All Hyperparameters
overwrite_output_dir: False
do_predict: False
eval_strategy: steps
prediction_loss_only: True
per_device_train_batch_size: 32
per_device_eval_batch_size: 32
per_gpu_train_batch_size: None
per_gpu_eval_batch_size: None
gradient_accumulation_steps: 1
eval_accumulation_steps: None
torch_empty_cache_steps: None
learning_rate: 1e-05
weight_decay: 0.01
adam_beta1: 0.9
adam_beta2: 0.999
adam_epsilon: 1e-08
max_grad_norm: 1.0
num_train_epochs: 10
max_steps: -1
lr_scheduler_type: linear
lr_scheduler_kwargs: {}
warmup_ratio: 0.1
warmup_steps: 144
log_level: passive
log_level_replica: warning
log_on_each_node: True
logging_nan_inf_filter: True
save_safetensors: True
save_on_each_node: False
save_only_model: False
restore_callback_states_from_checkpoint: False
no_cuda: False
use_cpu: False
use_mps_device: False
seed: 42
data_seed: None
jit_mode_eval: False
use_ipex: False
bf16: True
fp16: False
fp16_opt_level: O1
half_precision_backend: auto
bf16_full_eval: False
fp16_full_eval: False
tf32: None
local_rank: 0
ddp_backend: None
tpu_num_cores: None
tpu_metrics_debug: False
debug: []
dataloader_drop_last: False
dataloader_num_workers: 0
dataloader_prefetch_factor: None
past_index: -1
disable_tqdm: False
remove_unused_columns: True
label_names: None
load_best_model_at_end: False
ignore_data_skip: False
fsdp: []
fsdp_min_num_params: 0
fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
fsdp_transformer_layer_cls_to_wrap: None
accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
deepspeed: None
label_smoothing_factor: 0.0
optim: adamw_torch
optim_args: None
adafactor: False
group_by_length: False
length_column_name: length
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
use_legacy_prediction_loop: False
push_to_hub: False
resume_from_checkpoint: None
hub_model_id: None
hub_strategy: every_save
hub_private_repo: None
hub_always_push: False
gradient_checkpointing: False
gradient_checkpointing_kwargs: None
include_inputs_for_metrics: False
include_for_metrics: []
eval_do_concat_batches: True
fp16_backend: auto
push_to_hub_model_id: None
push_to_hub_organization: None
mp_parameters:
auto_find_batch_size: False
full_determinism: False
torchdynamo: None
ray_scope: last
ddp_timeout: 1800
torch_compile: False
torch_compile_backend: None
torch_compile_mode: None
include_tokens_per_second: False
include_num_input_tokens_seen: False
neftune_noise_alpha: None
optim_target_modules: None
batch_eval_metrics: False
eval_on_start: False
use_liger_kernel: False
eval_use_gather_object: False
average_tokens_across_devices: False
prompts: None
batch_sampler: batch_sampler
multi_dataset_batch_sampler: proportional
Training Logs
| Epoch | Step | Training Loss | Validation Loss | sts-dev_spearman_cosine | sts-test_spearman_cosine | all-nli-tr-test_cosine_accuracy | sts22-test_spearman_cosine | stsb-dev-768_spearman_cosine | stsb-dev-512_spearman_cosine | stsb-dev-256_spearman_cosine | stsb-dev-128_spearman_cosine | stsb-dev-64_spearman_cosine | stsb-test-768_spearman_cosine | stsb-test-512_spearman_cosine | stsb-test-256_spearman_cosine | stsb-test-128_spearman_cosine | stsb-test-64_spearman_cosine |
|---|
| 0.1327 | 1000 | 6.5142 | 3.0122 | 0.8163 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.2655 | 2000 | 3.063 | 2.5473 | 0.8284 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.3982 | 3000 | 2.5516 | 2.3314 | 0.8274 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.5310 | 4000 | 2.2681 | 2.2253 | 0.8330 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.6637 | 5000 | 2.1122 | 2.1568 | 0.8329 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.7965 | 6000 | 1.9427 | 2.0958 | 0.8359 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0.9292 | 7000 | 1.856 | 2.0770 | 0.8335 | - | - | - | - | - | - | - | - | - | - | - | - | - |
| -1 | -1 | - | - | - | 0.8081 | 0.9403 | 0.5340 | - | - | - | - | - | - | - | - | - | - |
| 1.1111 | 200 | 39.4792 | 29.2091 | - | - | - | - | 0.8327 | 0.8323 | 0.8284 | 0.8243 | 0.8135 | - | - | - | - | - |
| 2.2222 | 400 | 28.0902 | 29.4698 | - | - | - | - | 0.8539 | 0.8542 | 0.8509 | 0.8473 | 0.8387 | - | - | - | - | - |
| 3.3333 | 600 | 26.8504 | 31.4975 | - | - | - | - | 0.8532 | 0.8535 | 0.8495 | 0.8443 | 0.8376 | - | - | - | - | - |
| 4.4444 | 800 | 25.7399 | 33.3569 | - | - | - | - | 0.8538 | 0.8542 | 0.8505 | 0.8455 | 0.8378 | - | - | - | - | - |
| 5.5556 | 1000 | 24.6547 | 35.7253 | - | - | - | - | 0.8537 | 0.8545 | 0.8510 | 0.8459 | 0.8393 | - | - | - | - | - |
| 6.6667 | 1200 | 23.589 | 37.8066 | - | - | - | - | 0.8548 | 0.8557 | 0.8522 | 0.8466 | 0.8398 | - | - | - | - | - |
| 7.7778 | 1400 | 22.7868 | 39.3319 | - | - | - | - | 0.8546 | 0.8557 | 0.8521 | 0.8464 | 0.8396 | - | - | - | - | - |
| 8.8889 | 1600 | 22.2741 | 40.3429 | - | - | - | - | 0.8548 | 0.8560 | 0.8524 | 0.8466 | 0.8400 | - | - | - | - | - |
| 10.0 | 1800 | 21.9617 | 40.6515 | - | - | - | - | 0.8546 | 0.8557 | 0.8521 | 0.8463 | 0.8399 | - | - | - | - | - |
| -1 | -1 | - | - | - | - | - | - | - | - | - | - | - | 0.8327 | 0.8334 | 0.8315 | 0.8267 | 0.8155 |
Framework Versions
- Python: 3.11.13
- Sentence Transformers: 4.1.0
- Transformers: 4.52.4
- PyTorch: 2.6.0+cu124
- Accelerate: 1.7.0
- Datasets: 3.6.0
- Tokenizers: 0.21.1
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",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
CoSENTLoss
@online{kexuefm-8847,
title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
author={Su Jianlin},
year={2022},
month={Jan},
url={https://kexue.fm/archives/8847},
}