SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
This is a sentence-transformers model finetuned from sentence-transformers/all-mpnet-base-v2. 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: sentence-transformers/all-mpnet-base-v2
- Maximum Sequence Length: 384 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': 384, 'do_lower_case': False}) with Transformer model: MPNetModel
(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})
(2): Normalize()
)
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 = [
'I am not good at expressing my true feelings by the way I talk and look.',
'Felt nervous or anxious?',
'Experienced sleep disturbances?',
]
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
- Evaluated with
EmbeddingSimilarityEvaluator
| Metric | Value |
|---|---|
| pearson_cosine | 0.568 |
| spearman_cosine | 0.5533 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 2,351 training samples
- Columns:
sentence1,sentence2, andscore - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 score type string string float details - min: 5 tokens
- mean: 16.73 tokens
- max: 47 tokens
- min: 5 tokens
- mean: 14.82 tokens
- max: 28 tokens
- min: 0.0
- mean: 0.26
- max: 1.0
- Samples:
sentence1 sentence2 score Do you believe in telepathy (mind-reading)?I believe that there are secret signs in the world if you just know how to look for them.0.15Irritable behavior, angry outbursts, or acting aggressively?Felt โon edgeโ?0.62I have some eccentric (odd) habits.I often have difficulty following what someone is saying to me.0.0 - Loss:
CosineSimilarityLosswith these parameters:{ "loss_fct": "torch.nn.modules.loss.L1Loss" }
Evaluation Dataset
Unnamed Dataset
- Size: 236 evaluation samples
- Columns:
sentence1,sentence2, andscore - Approximate statistics based on the first 236 samples:
sentence1 sentence2 score type string string float details - min: 6 tokens
- mean: 16.4 tokens
- max: 47 tokens
- min: 5 tokens
- mean: 14.76 tokens
- max: 28 tokens
- min: 0.0
- mean: 0.29
- max: 1.0
- Samples:
sentence1 sentence2 score Feeling afraid as if something awful might happen?I have trouble following conversations with others.0.19Do you believe in telepathy (mind-reading)?Feeling jumpy or easily startled?0.1Other people see me as slightly eccentric (odd).I have felt that there were messages for me in the way things were arranged, like furniture in a room.0.0 - Loss:
CosineSimilarityLosswith these parameters:{ "loss_fct": "torch.nn.modules.loss.L1Loss" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 16
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_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: Falseuse_ipex: Falsebf16: Falsefp16: Falsefp16_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_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: Falsegradient_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: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional
Training Logs
| Epoch | Step | Training Loss | Validation Loss | spearman_cosine |
|---|---|---|---|---|
| 0.0680 | 10 | 0.2239 | - | - |
| 0.1361 | 20 | 0.2188 | - | - |
| 0.2041 | 30 | 0.2007 | - | - |
| 0.2721 | 40 | 0.2045 | - | - |
| 0.3401 | 50 | 0.2179 | 0.2197 | - |
| 0.4082 | 60 | 0.2106 | - | - |
| 0.4762 | 70 | 0.2124 | - | - |
| 0.5442 | 80 | 0.2046 | - | - |
| 0.6122 | 90 | 0.2069 | - | - |
| 0.6803 | 100 | 0.1965 | 0.2112 | - |
| 0.7483 | 110 | 0.2355 | - | - |
| 0.8163 | 120 | 0.2012 | - | - |
| 0.8844 | 130 | 0.2402 | - | - |
| 0.9524 | 140 | 0.2173 | - | - |
| 1.0204 | 150 | 0.1763 | 0.2043 | - |
| 1.0884 | 160 | 0.1862 | - | - |
| 1.1565 | 170 | 0.1854 | - | - |
| 1.2245 | 180 | 0.193 | - | - |
| 1.2925 | 190 | 0.1852 | - | - |
| 1.3605 | 200 | 0.1908 | 0.1950 | - |
| 1.4286 | 210 | 0.2002 | - | - |
| 1.4966 | 220 | 0.1945 | - | - |
| 1.5646 | 230 | 0.193 | - | - |
| 1.6327 | 240 | 0.1893 | - | - |
| 1.7007 | 250 | 0.171 | 0.1937 | - |
| 1.7687 | 260 | 0.1848 | - | - |
| 1.8367 | 270 | 0.1909 | - | - |
| 1.9048 | 280 | 0.2138 | - | - |
| 1.9728 | 290 | 0.2014 | - | - |
| 2.0408 | 300 | 0.1855 | 0.1867 | - |
| 2.1088 | 310 | 0.1891 | - | - |
| 2.1769 | 320 | 0.1849 | - | - |
| 2.2449 | 330 | 0.1741 | - | - |
| 2.3129 | 340 | 0.1775 | - | - |
| 2.3810 | 350 | 0.178 | 0.1871 | - |
| 2.4490 | 360 | 0.1778 | - | - |
| 2.5170 | 370 | 0.174 | - | - |
| 2.5850 | 380 | 0.1654 | - | - |
| 2.6531 | 390 | 0.1954 | - | - |
| 2.7211 | 400 | 0.1584 | 0.1860 | - |
| 2.7891 | 410 | 0.2019 | - | - |
| 2.8571 | 420 | 0.1941 | - | - |
| 2.9252 | 430 | 0.1855 | - | - |
| 2.9932 | 440 | 0.1823 | - | - |
| 3.0 | 441 | - | - | 0.5533 |
Framework Versions
- Python: 3.10.12
- Sentence Transformers: 3.3.1
- Transformers: 4.47.1
- PyTorch: 2.5.1+cu121
- Accelerate: 1.2.1
- Datasets: 3.2.0
- Tokenizers: 0.21.0
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",
}
- Downloads last month
- 119
Model tree for harmonydata/mental_health_harmonisation_1
Base model
sentence-transformers/all-mpnet-base-v2Evaluation results
- Pearson Cosine on Unknownself-reported0.568
- Spearman Cosine on Unknownself-reported0.553