--- language: - en library_name: sentence-transformers tags: - sentence-transformers - sentence-similarity - feature-extraction - dataset_size:100K - **Maximum Sequence Length:** 512 tokens - **Output Dimensionality:** 768 tokens - **Similarity Function:** Cosine Similarity - **Training Dataset:** - [stanfordnlp/snli](https://huggingface.co/datasets/stanfordnlp/snli) - **Language:** en ### Model Sources - **Documentation:** [Sentence Transformers Documentation](https://sbert.net) - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers) - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers) ### Full Model Architecture ``` SentenceTransformer( (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: DebertaV2Model (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: ```bash pip install -U sentence-transformers ``` Then you can load this model and run inference. ```python from sentence_transformers import SentenceTransformer # Download from the 🤗 Hub model = SentenceTransformer("bobox/DeBERTaV3-large-SentenceTransformer-0.01n") # Run inference sentences = [ 'Are you sure?', 'Are you certain?', 'Both of the men are walking.', ] 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](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) | Metric | Value | |:--------------------|:-----------| | pearson_cosine | 0.3561 | | **spearman_cosine** | **0.4042** | | pearson_manhattan | 0.4447 | | spearman_manhattan | 0.4644 | | pearson_euclidean | 0.4074 | | spearman_euclidean | 0.4281 | | pearson_dot | -0.0336 | | spearman_dot | -0.0261 | | pearson_max | 0.4447 | | spearman_max | 0.4644 | #### Binary Classification * Evaluated with [BinaryClassificationEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.BinaryClassificationEvaluator) | Metric | Value | |:-----------------------------|:-----------| | cosine_accuracy | 0.6743 | | cosine_accuracy_threshold | 0.693 | | cosine_f1 | 0.7185 | | cosine_f1_threshold | 0.5344 | | cosine_precision | 0.5971 | | cosine_recall | 0.902 | | cosine_ap | 0.7445 | | dot_accuracy | 0.6597 | | dot_accuracy_threshold | 273.9874 | | dot_f1 | 0.7171 | | dot_f1_threshold | 223.5422 | | dot_precision | 0.6022 | | dot_recall | 0.8861 | | dot_ap | 0.7124 | | manhattan_accuracy | 0.6608 | | manhattan_accuracy_threshold | 318.3035 | | manhattan_f1 | 0.706 | | manhattan_f1_threshold | 386.4444 | | manhattan_precision | 0.5927 | | manhattan_recall | 0.8728 | | manhattan_ap | 0.7339 | | euclidean_accuracy | 0.6594 | | euclidean_accuracy_threshold | 15.6948 | | euclidean_f1 | 0.7073 | | euclidean_f1_threshold | 21.0095 | | euclidean_precision | 0.5743 | | euclidean_recall | 0.9203 | | euclidean_ap | 0.7343 | | max_accuracy | 0.6743 | | max_accuracy_threshold | 318.3035 | | max_f1 | 0.7185 | | max_f1_threshold | 386.4444 | | max_precision | 0.6022 | | max_recall | 0.9203 | | **max_ap** | **0.7445** | ## Training Details ### Training Dataset #### stanfordnlp/snli * Dataset: [stanfordnlp/snli](https://huggingface.co/datasets/stanfordnlp/snli) at [cdb5c3d](https://huggingface.co/datasets/stanfordnlp/snli/tree/cdb5c3d5eed6ead6e5a341c8e56e669bb666725b) * Size: 314,315 training samples * Columns: sentence1, sentence2, and label * Approximate statistics based on the first 1000 samples: | | sentence1 | sentence2 | label | |:--------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:-----------------------------| | type | string | string | int | | details | | | | * Samples: | sentence1 | sentence2 | label | |:---------------------------------------------------------------------------|:-------------------------------------------------|:---------------| | A person on a horse jumps over a broken down airplane. | A person is outdoors, on a horse. | 0 | | Children smiling and waving at camera | There are children present | 0 | | A boy is jumping on skateboard in the middle of a red bridge. | The boy does a skateboarding trick. | 0 | * Loss: [MultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters: ```json { "scale": 20.0, "similarity_fct": "cos_sim" } ``` ### Evaluation Dataset #### sentence-transformers/stsb * Dataset: [sentence-transformers/stsb](https://huggingface.co/datasets/sentence-transformers/stsb) at [ab7a5ac](https://huggingface.co/datasets/sentence-transformers/stsb/tree/ab7a5ac0e35aa22088bdcf23e7fd99b220e53308) * Size: 13,189 evaluation samples * Columns: premise, hypothesis, and label * Approximate statistics based on the first 1000 samples: | | premise | hypothesis | label | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:------------------------------------------------| | type | string | string | int | | details | | | | * Samples: | premise | hypothesis | label | |:--------------------------------------------------------------------------------------------------------|:---------------------------------------------------|:---------------| | This church choir sings to the masses as they sing joyous songs from the book at a church. | The church has cracks in the ceiling. | 0 | | This church choir sings to the masses as they sing joyous songs from the book at a church. | The church is filled with song. | 1 | | A woman with a green headscarf, blue shirt and a very big grin. | The woman is young. | 0 | * Loss: [MultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters: ```json { "scale": 20.0, "similarity_fct": "cos_sim" } ``` ### Training Hyperparameters #### Non-Default Hyperparameters - `eval_strategy`: steps - `per_device_train_batch_size`: 32 - `per_device_eval_batch_size`: 64 - `num_train_epochs`: 5 - `lr_scheduler_type`: cosine - `warmup_ratio`: 0.25 - `save_safetensors`: False - `fp16`: True - `push_to_hub`: True - `hub_model_id`: bobox/DeBERTaV3-large-SentenceTransformer-0.01n - `hub_strategy`: checkpoint - `batch_sampler`: no_duplicates #### All Hyperparameters
Click to expand - `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`: 64 - `per_gpu_train_batch_size`: None - `per_gpu_eval_batch_size`: None - `gradient_accumulation_steps`: 1 - `eval_accumulation_steps`: None - `learning_rate`: 5e-05 - `weight_decay`: 0.0 - `adam_beta1`: 0.9 - `adam_beta2`: 0.999 - `adam_epsilon`: 1e-08 - `max_grad_norm`: 1.0 - `num_train_epochs`: 5 - `max_steps`: -1 - `lr_scheduler_type`: cosine - `lr_scheduler_kwargs`: {} - `warmup_ratio`: 0.25 - `warmup_steps`: 0 - `log_level`: passive - `log_level_replica`: warning - `log_on_each_node`: True - `logging_nan_inf_filter`: True - `save_safetensors`: False - `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`: False - `fp16`: True - `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`: True - `resume_from_checkpoint`: None - `hub_model_id`: bobox/DeBERTaV3-large-SentenceTransformer-0.01n - `hub_strategy`: checkpoint - `hub_private_repo`: False - `hub_always_push`: False - `gradient_checkpointing`: False - `gradient_checkpointing_kwargs`: None - `include_inputs_for_metrics`: False - `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 - `dispatch_batches`: None - `split_batches`: None - `include_tokens_per_second`: False - `include_num_input_tokens_seen`: False - `neftune_noise_alpha`: None - `optim_target_modules`: None - `batch_eval_metrics`: False - `batch_sampler`: no_duplicates - `multi_dataset_batch_sampler`: proportional
### Training Logs | Epoch | Step | Training Loss | loss | max_ap | spearman_cosine | |:------:|:-----:|:-------------:|:------:|:------:|:---------------:| | None | 0 | - | 3.2007 | 0.5917 | 0.4042 | | 0.1250 | 1228 | 2.3115 | 1.3295 | 0.6783 | - | | 0.2500 | 2456 | 1.1344 | 1.0007 | 0.7048 | - | | 0.3750 | 3684 | 0.9827 | 0.8551 | 0.7091 | - | | 0.5001 | 4912 | 0.9045 | 0.7483 | 0.7148 | - | | 0.6251 | 6140 | 0.6488 | 0.6057 | 0.7276 | - | | 0.7501 | 7368 | 0.1224 | 0.6683 | 0.7358 | - | | 0.8751 | 8596 | 0.1063 | 0.6895 | 0.7294 | - | | 1.0001 | 9824 | 0.0959 | 0.7052 | 0.7325 | - | | 1.1251 | 11052 | 0.8908 | 0.5446 | 0.7343 | - | | 1.2501 | 12280 | 0.8212 | 0.5973 | 0.7225 | - | | 1.3751 | 13508 | 0.7871 | 0.6420 | 0.7078 | - | | 1.5002 | 14736 | 0.7547 | 0.6057 | 0.7135 | - | | 1.6252 | 15964 | 0.5267 | 0.5308 | 0.7370 | - | | 1.7502 | 17192 | 0.0619 | 0.5269 | 0.7348 | - | | 1.8752 | 18420 | 0.0509 | 0.5550 | 0.7378 | - | | 2.0002 | 19648 | 0.044 | 0.5835 | 0.7359 | - | | 2.1252 | 20876 | 0.7125 | 0.4636 | 0.7351 | - | | 2.2502 | 22104 | 0.6542 | 0.4919 | 0.7358 | - | | 2.3752 | 23332 | 0.6273 | 0.4758 | 0.7219 | - | | 2.5003 | 24560 | 0.5972 | 0.4816 | 0.7279 | - | | 2.6253 | 25788 | 0.3981 | 0.4526 | 0.7463 | - | | 2.7503 | 27016 | 0.0169 | 0.4568 | 0.7446 | - | | 2.8753 | 28244 | 0.0142 | 0.4995 | 0.7445 | - | ### Framework Versions - Python: 3.10.12 - Sentence Transformers: 3.0.0 - Transformers: 4.41.2 - PyTorch: 2.3.0+cu121 - Accelerate: 0.30.1 - Datasets: 2.19.2 - Tokenizers: 0.19.1 ## Citation ### BibTeX #### Sentence Transformers ```bibtex @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 ```bibtex @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} } ```