SentenceTransformer based on jhu-clsp/mmBERT-base
This is a sentence-transformers model finetuned from jhu-clsp/mmBERT-base. 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: jhu-clsp/mmBERT-base
- Maximum Sequence Length: 8192 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, '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
# Download from the 🤗 Hub
model = SentenceTransformer("8Opt/mmbert-base-vn-sts-001")
# Run inference
sentences = [
'Một người đàn ông đang ngồi gần một chiếc xe đạp và đang viết một ghi chú',
'Một người đàn ông mặc quần áo được phủ sơn và đang ngồi bên ngoài trong một khu vực đông đúc để viết một cái gì đó',
'Các vận động viên khuyết tật chuẩn bị sẵn sàng, làm dấy lên những câu hỏi về hậu cần và sự công bằng.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8503, 0.7796],
# [0.8503, 1.0000, 0.7599],
# [0.7796, 0.7599, 1.0000]])
Evaluation
Metrics
Semantic Similarity
- Datasets:
8Opt-sts-dev-0001and8Opt-sts-test-0002 - Evaluated with
EmbeddingSimilarityEvaluator
| Metric | 8Opt-sts-dev-0001 | 8Opt-sts-test-0002 |
|---|---|---|
| pearson_cosine | 0.7113 | 0.7113 |
| spearman_cosine | 0.7318 | 0.7318 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 28,990 training samples
- Columns:
sentence1,sentence2, andscore - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 6 tokens
- mean: 18.02 tokens
- max: 74 tokens
- min: 5 tokens
- mean: 17.77 tokens
- max: 81 tokens
- min: 0.04
- mean: 2.6
- max: 5.0
- Samples:
sentence1 sentence2 score Một con chó đen đang chạy trong tuyết.Một con chó đen đang chạy trên bãi biển.1.8bóng đèn a tạo ra một khoảng trốngnếu bóng đèn a cháy ra, cả b và c đều không ở trong một đường kín1.8Sự phát triển an ninh tại Iraq, ngày 1 tháng 2Sự phát triển an ninh tại Pakistan, ngày 13 tháng 31.6 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Evaluation Dataset
Unnamed Dataset
- Size: 4,141 evaluation samples
- Columns:
sentence1,sentence2, andscore - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 3 tokens
- mean: 18.71 tokens
- max: 107 tokens
- min: 4 tokens
- mean: 17.54 tokens
- max: 91 tokens
- min: 0.04
- mean: 2.56
- max: 5.0
- Samples:
sentence1 sentence2 score một đơn vị đáp ứng các điều kiện tiên quyết để tham gia vào một sự kiện. một mức độ sửa đổi có thể được bao gồm để chỉ ra bao nhiêu đơn vị vượt quá hoặc không đạt được các yêu cầu tối thiểu.(thường theo sau là `to ') có phương tiện cần thiết hoặc kỹ năng hoặc bí quyết hoặc thẩm quyền để làm một cái gì đó;0.4Tôi sẽ không đưa nó vào hồ sơ của mình.Tôi sẽ không đưa công việc này vào hồ sơ của mình.4.0Một cậu bé trẻ với một chiếc áo khoác chứa tim đang nâng tay lên khi anh ta trượtMột đứa trẻ tóc vàng đang đi xuống một slide và ném lên tay của mình3.7 - Loss:
CoSENTLosswith these parameters:{ "scale": 20.0, "similarity_fct": "pairwise_cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 2e-05num_train_epochs: 5warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 5max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss | Validation Loss | 8Opt-sts-dev-0001_spearman_cosine | 8Opt-sts-test-0002_spearman_cosine |
|---|---|---|---|---|---|
| 0.1104 | 100 | 6.2285 | 6.1894 | 0.4639 | - |
| 0.2208 | 200 | 6.0912 | 6.0358 | 0.5950 | - |
| 0.3311 | 300 | 6.0572 | 6.0373 | 0.6327 | - |
| 0.4415 | 400 | 5.9895 | 5.9931 | 0.6654 | - |
| 0.5519 | 500 | 5.9872 | 5.9771 | 0.6707 | - |
| 0.6623 | 600 | 5.9583 | 5.9619 | 0.6785 | - |
| 0.7726 | 700 | 5.9517 | 5.9831 | 0.6930 | - |
| 0.8830 | 800 | 5.9866 | 5.9433 | 0.6980 | - |
| 0.9934 | 900 | 5.9541 | 5.9460 | 0.6964 | - |
| 1.1038 | 1000 | 5.8652 | 5.9386 | 0.7174 | - |
| 1.2141 | 1100 | 5.8577 | 5.9361 | 0.7077 | - |
| 1.3245 | 1200 | 5.8518 | 5.9412 | 0.7201 | - |
| 1.4349 | 1300 | 5.8636 | 5.9255 | 0.7257 | - |
| 1.5453 | 1400 | 5.8342 | 5.9430 | 0.7134 | - |
| 1.6556 | 1500 | 5.8309 | 5.9765 | 0.7177 | - |
| 1.7660 | 1600 | 5.853 | 5.9125 | 0.7289 | - |
| 1.8764 | 1700 | 5.8369 | 5.9112 | 0.7324 | - |
| 1.9868 | 1800 | 5.8504 | 5.9032 | 0.7335 | - |
| 2.0971 | 1900 | 5.7031 | 5.9822 | 0.7343 | - |
| 2.2075 | 2000 | 5.6934 | 6.0005 | 0.7328 | - |
| 2.3179 | 2100 | 5.6574 | 6.0913 | 0.7277 | - |
| 2.4283 | 2200 | 5.6671 | 6.0513 | 0.7255 | - |
| 2.5386 | 2300 | 5.6632 | 5.9786 | 0.7325 | - |
| 2.6490 | 2400 | 5.6746 | 6.0000 | 0.7342 | - |
| 2.7594 | 2500 | 5.6995 | 5.9492 | 0.7366 | - |
| 2.8698 | 2600 | 5.6814 | 6.0296 | 0.7315 | - |
| 2.9801 | 2700 | 5.6689 | 6.0508 | 0.7310 | - |
| 3.0905 | 2800 | 5.4825 | 6.2192 | 0.7296 | - |
| 3.2009 | 2900 | 5.4686 | 6.2524 | 0.7295 | - |
| 3.3113 | 3000 | 5.4698 | 6.1861 | 0.7294 | - |
| 3.4216 | 3100 | 5.4957 | 6.2815 | 0.7296 | - |
| 3.5320 | 3200 | 5.4993 | 6.2204 | 0.7309 | - |
| 3.6424 | 3300 | 5.5112 | 6.1372 | 0.7334 | - |
| 3.7528 | 3400 | 5.5259 | 6.1005 | 0.7337 | - |
| 3.8631 | 3500 | 5.5144 | 6.2305 | 0.7329 | - |
| 3.9735 | 3600 | 5.4785 | 6.1930 | 0.7354 | - |
| 4.0839 | 3700 | 5.367 | 6.5986 | 0.7276 | - |
| 4.1943 | 3800 | 5.2908 | 6.6695 | 0.7259 | - |
| 4.3046 | 3900 | 5.3125 | 6.6357 | 0.7264 | - |
| 4.4150 | 4000 | 5.2967 | 6.6588 | 0.7296 | - |
| 4.5254 | 4100 | 5.3019 | 6.6631 | 0.7313 | - |
| 4.6358 | 4200 | 5.2951 | 6.7149 | 0.7327 | - |
| 4.7461 | 4300 | 5.2609 | 6.7235 | 0.7323 | - |
| 4.8565 | 4400 | 5.2969 | 6.6987 | 0.7319 | - |
| 4.9669 | 4500 | 5.2938 | 6.7005 | 0.7318 | - |
| -1 | -1 | - | - | - | 0.7318 |
Framework Versions
- Python: 3.12.12
- Sentence Transformers: 5.1.2
- Transformers: 4.57.1
- PyTorch: 2.8.0+cu126
- Accelerate: 1.11.0
- Datasets: 4.0.0
- Tokenizers: 0.22.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",
}
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}
}
- Downloads last month
- 5
Model tree for 8Opt/mmbert-base-vn-sts-001
Base model
jhu-clsp/mmBERT-baseEvaluation results
- Pearson Cosine on 8Opt sts dev 0001self-reported0.711
- Spearman Cosine on 8Opt sts dev 0001self-reported0.732
- Pearson Cosine on 8Opt sts test 0002self-reported0.711
- Spearman Cosine on 8Opt sts test 0002self-reported0.732