--- base_model: distilbert/distilroberta-base library_name: sentence-transformers pipeline_tag: sentence-similarity tags: - sentence-transformers - sentence-similarity - feature-extraction - generated_from_trainer - dataset_size:50881 - loss:TripletLoss widget: - source_sentence: How can we reduce fatty thighs? sentences: - Is running beneficial for burning thigh and hips fat? - Do mosquitoes get trapped in spider webs? - How can I reduce thigh fat? - source_sentence: What does Balaji Vishwanathan think about the ban of ₹500 and ₹1000 currency notes in India? sentences: - What are your views on demonetization of ₹500 & ₹1000 notes in India? - What is your view on Meenakshi Lekhi, a MP of BJP, suggesting that demonetization will hurt the common people? - What are some good horror movies? - source_sentence: What are your New Years resolutions for 2017? sentences: - What are some meaningful new year resolutions for 2017? - How close are we to world war? - What are your New Year's resolutions for 2016? - source_sentence: Which will be the best day of your life? sentences: - Can you describe the best moment or the best day in your life? - How was your day? What did you do today? - Is it possible to travel time with real life? - source_sentence: What is the best way to learn to play piano? sentences: - How can I learn to play the piano/synthesizer? - What are the facilities to an IES officer? - Can I easily learn a piano at a later point if I start learning music with a keyboard initially? --- # SentenceTransformer based on distilbert/distilroberta-base This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [distilbert/distilroberta-base](https://huggingface.co/distilbert/distilroberta-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:** [distilbert/distilroberta-base](https://huggingface.co/distilbert/distilroberta-base) - **Maximum Sequence Length:** 512 tokens - **Output Dimensionality:** 768 tokens - **Similarity Function:** Cosine Similarity ### 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: RobertaModel (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("AhmedSSoliman/distilroberta-base-sentence-transformer") # Run inference sentences = [ 'What is the best way to learn to play piano?', 'How can I learn to play the piano/synthesizer?', 'Can I easily learn a piano at a later point if I start learning music with a keyboard initially?', ] 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] ``` ## Training Details ### Training Dataset #### Unnamed Dataset * Size: 50,881 training samples * Columns: sentence_0, sentence_1, and sentence_2 * Approximate statistics based on the first 1000 samples: | | sentence_0 | sentence_1 | sentence_2 | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | string | | details | | | | * Samples: | sentence_0 | sentence_1 | sentence_2 | |:--------------------------------------------------------|:-----------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------| | What does Donald Trump think of India? | Donald Trump: What is Donald Trump's take on India? Will it affect Indians? | How is the presidency of Donald Trump going to affect India's IT industry? | | What is the best way to whiten your teeth? | What can I do to whiten my teeth? | Can you get teeth whitening even if you have a cavity? | | How can we meet to PM Narendra Modi? | How can I meet Narendra Modi if it's very important? | How can I contact PM Narendra Modi Ji if I know anyone who may have black money? | * Loss: [TripletLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#tripletloss) with these parameters: ```json { "distance_metric": "TripletDistanceMetric.EUCLIDEAN", "triplet_margin": 5 } ``` ### Training Hyperparameters #### Non-Default Hyperparameters - `per_device_train_batch_size`: 16 - `per_device_eval_batch_size`: 16 - `num_train_epochs`: 10 - `multi_dataset_batch_sampler`: round_robin #### All Hyperparameters
Click to expand - `overwrite_output_dir`: False - `do_predict`: False - `eval_strategy`: no - `prediction_loss_only`: True - `per_device_train_batch_size`: 16 - `per_device_eval_batch_size`: 16 - `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`: 5e-05 - `weight_decay`: 0.0 - `adam_beta1`: 0.9 - `adam_beta2`: 0.999 - `adam_epsilon`: 1e-08 - `max_grad_norm`: 1 - `num_train_epochs`: 10 - `max_steps`: -1 - `lr_scheduler_type`: linear - `lr_scheduler_kwargs`: {} - `warmup_ratio`: 0.0 - `warmup_steps`: 0 - `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`: False - `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`: 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 - `eval_on_start`: False - `use_liger_kernel`: False - `eval_use_gather_object`: False - `batch_sampler`: batch_sampler - `multi_dataset_batch_sampler`: round_robin
### Training Logs | Epoch | Step | Training Loss | |:------:|:-----:|:-------------:| | 0.3143 | 500 | 3.4002 | | 0.6285 | 1000 | 1.4741 | | 0.9428 | 1500 | 1.0103 | | 1.2571 | 2000 | 0.7645 | | 1.5713 | 2500 | 0.6256 | | 1.8856 | 3000 | 0.5197 | | 2.1999 | 3500 | 0.4278 | | 2.5141 | 4000 | 0.3611 | | 2.8284 | 4500 | 0.2858 | | 3.1427 | 5000 | 0.236 | | 3.4569 | 5500 | 0.2013 | | 3.7712 | 6000 | 0.1623 | | 4.0855 | 6500 | 0.1395 | | 4.3997 | 7000 | 0.1112 | | 4.7140 | 7500 | 0.1033 | | 5.0283 | 8000 | 0.0853 | | 5.3426 | 8500 | 0.0716 | | 5.6568 | 9000 | 0.0644 | | 5.9711 | 9500 | 0.0577 | | 6.2854 | 10000 | 0.0522 | | 6.5996 | 10500 | 0.0444 | | 6.9139 | 11000 | 0.0417 | | 7.2282 | 11500 | 0.0328 | | 7.5424 | 12000 | 0.0326 | | 7.8567 | 12500 | 0.0326 | | 8.1710 | 13000 | 0.0267 | | 8.4852 | 13500 | 0.0234 | | 8.7995 | 14000 | 0.025 | | 9.1138 | 14500 | 0.0224 | | 9.4280 | 15000 | 0.0198 | | 9.7423 | 15500 | 0.0206 | ### Framework Versions - Python: 3.12.6 - Sentence Transformers: 3.1.1 - Transformers: 4.45.1 - PyTorch: 2.4.1+cu121 - Accelerate: 0.34.2 - Datasets: 3.0.1 - Tokenizers: 0.20.0 ## 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", } ``` #### TripletLoss ```bibtex @misc{hermans2017defense, title={In Defense of the Triplet Loss for Person Re-Identification}, author={Alexander Hermans and Lucas Beyer and Bastian Leibe}, year={2017}, eprint={1703.07737}, archivePrefix={arXiv}, primaryClass={cs.CV} } ```