--- base_model: Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2 datasets: - Omartificial-Intelligence-Space/Arabic-stsb language: - ar library_name: sentence-transformers metrics: - pearson_cosine - spearman_cosine - pearson_manhattan - spearman_manhattan - pearson_euclidean - spearman_euclidean - pearson_dot - spearman_dot - pearson_max - spearman_max pipeline_tag: sentence-similarity tags: - sentence-transformers - sentence-similarity - feature-extraction - generated_from_trainer - dataset_size:947818 - loss:SoftmaxLoss - loss:CosineSimilarityLoss widget: - source_sentence: امرأة تكتب شيئاً sentences: - مراهق يتحدث إلى فتاة عبر كاميرا الإنترنت - امرأة تقطع البصل الأخضر. - مجموعة من كبار السن يتظاهرون حول طاولة الطعام. - source_sentence: تتشكل النجوم في مناطق تكوين النجوم، والتي تنشأ نفسها من السحب الجزيئية. sentences: - لاعب كرة السلة على وشك تسجيل نقاط لفريقه. - المقال التالي مأخوذ من نسختي من "أطلس البطريق الجديد للتاريخ الوسطى" - قد يكون من الممكن أن يوجد نظام شمسي مثل نظامنا خارج المجرة - source_sentence: تحت السماء الزرقاء مع الغيوم البيضاء، يصل طفل لمس مروحة طائرة واقفة على حقل من العشب. sentences: - امرأة تحمل كأساً - طفل يحاول لمس مروحة طائرة - اثنان من عازبين عن الشرب يستعدون للعشاء - source_sentence: رجل في منتصف العمر يحلق لحيته في غرفة ذات جدران بيضاء والتي لا تبدو كحمام sentences: - فتى يخطط اسمه على مكتبه - رجل ينام - المرأة وحدها وهي نائمة في غرفة نومها - source_sentence: الكلب البني مستلقي على جانبه على سجادة بيج، مع جسم أخضر في المقدمة. sentences: - شخص طويل القامة - المرأة تنظر من النافذة. - لقد مات الكلب model-index: - name: SentenceTransformer based on Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2 results: - task: type: semantic-similarity name: Semantic Similarity dataset: name: sts dev type: sts-dev metrics: - type: pearson_cosine value: 0.8390853221830158 name: Pearson Cosine - type: spearman_cosine value: 0.8410008255002589 name: Spearman Cosine - type: pearson_manhattan value: 0.8276538954353795 name: Pearson Manhattan - type: spearman_manhattan value: 0.8360889200075982 name: Spearman Manhattan - type: pearson_euclidean value: 0.8274021671008013 name: Pearson Euclidean - type: spearman_euclidean value: 0.8357887501417183 name: Spearman Euclidean - type: pearson_dot value: 0.8154259766643255 name: Pearson Dot - type: spearman_dot value: 0.81802827956939 name: Spearman Dot - type: pearson_max value: 0.8390853221830158 name: Pearson Max - type: spearman_max value: 0.8410008255002589 name: Spearman Max - task: type: semantic-similarity name: Semantic Similarity dataset: name: sts test type: sts-test metrics: - type: pearson_cosine value: 0.8130046542366043 name: Pearson Cosine - type: spearman_cosine value: 0.8172511596569861 name: Spearman Cosine - type: pearson_manhattan value: 0.8113865863454744 name: Pearson Manhattan - type: spearman_manhattan value: 0.8164081961542164 name: Spearman Manhattan - type: pearson_euclidean value: 0.810311097439534 name: Pearson Euclidean - type: spearman_euclidean value: 0.8157654465052717 name: Spearman Euclidean - type: pearson_dot value: 0.7907732563794702 name: Pearson Dot - type: spearman_dot value: 0.7886749863194292 name: Spearman Dot - type: pearson_max value: 0.8130046542366043 name: Pearson Max - type: spearman_max value: 0.8172511596569861 name: Spearman Max --- # SentenceTransformer based on Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2 This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2](https://huggingface.co/Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2) on the all-nli and [sts](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb) datasets. 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:** [Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2](https://huggingface.co/Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2) - **Maximum Sequence Length:** 512 tokens - **Output Dimensionality:** 768 tokens - **Similarity Function:** Cosine Similarity - **Training Datasets:** - all-nli - [sts](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb) - **Language:** ar ### 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: BertModel (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("Omartificial-Intelligence-Space/Arabic-Triplet-Matryoshka-V2-multi-tas-v2k") # Run inference sentences = [ 'الكلب البني مستلقي على جانبه على سجادة بيج، مع جسم أخضر في المقدمة.', 'لقد مات الكلب', 'شخص طويل القامة', ] 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 * Dataset: `sts-dev` * Evaluated with [EmbeddingSimilarityEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) | Metric | Value | |:--------------------|:----------| | pearson_cosine | 0.8391 | | **spearman_cosine** | **0.841** | | pearson_manhattan | 0.8277 | | spearman_manhattan | 0.8361 | | pearson_euclidean | 0.8274 | | spearman_euclidean | 0.8358 | | pearson_dot | 0.8154 | | spearman_dot | 0.818 | | pearson_max | 0.8391 | | spearman_max | 0.841 | #### Semantic Similarity * Dataset: `sts-test` * Evaluated with [EmbeddingSimilarityEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator) | Metric | Value | |:--------------------|:-----------| | pearson_cosine | 0.813 | | **spearman_cosine** | **0.8173** | | pearson_manhattan | 0.8114 | | spearman_manhattan | 0.8164 | | pearson_euclidean | 0.8103 | | spearman_euclidean | 0.8158 | | pearson_dot | 0.7908 | | spearman_dot | 0.7887 | | pearson_max | 0.813 | | spearman_max | 0.8173 | ## Training Details ### Training Datasets #### all-nli * Dataset: all-nli * Size: 942,069 training 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 | |:-----------------------------------------------|:--------------------------------------------|:---------------| | شخص على حصان يقفز فوق طائرة معطلة | شخص يقوم بتدريب حصانه للمنافسة | 1 | | شخص على حصان يقفز فوق طائرة معطلة | شخص في مطعم، يطلب عجة. | 2 | | شخص على حصان يقفز فوق طائرة معطلة | شخص في الهواء الطلق، على حصان. | 0 | * Loss: [SoftmaxLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#softmaxloss) #### sts * Dataset: [sts](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb) at [f5a6f89](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb/tree/f5a6f89da460d307eff3acbbfcb62d0705cdbbb5) * 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 | | | | * Samples: | sentence1 | sentence2 | score | |:-----------------------------------------------|:--------------------------------------------------------|:------------------| | طائرة ستقلع | طائرة جوية ستقلع | 1.0 | | رجل يعزف على ناي كبير | رجل يعزف على الناي. | 0.76 | | رجل ينشر الجبن الممزق على البيتزا | رجل ينشر الجبن الممزق على بيتزا غير مطبوخة | 0.76 | * Loss: [CosineSimilarityLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters: ```json { "loss_fct": "torch.nn.modules.loss.MSELoss" } ``` ### Evaluation Datasets #### all-nli * Dataset: all-nli * Size: 1,000 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 | |:------------------------------------------------|:------------------------------------------------------------------------------|:---------------| | امرأتان يتعانقان بينما يحملان طرود | الأخوات يعانقون بعضهم لوداعاً بينما يحملون حزمة بعد تناول الغداء | 1 | | امرأتان يتعانقان بينما يحملان حزمة | إمرأتان يحملان حزمة | 0 | | امرأتان يتعانقان بينما يحملان حزمة | الرجال يتشاجرون خارج مطعم | 2 | * Loss: [SoftmaxLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#softmaxloss) #### sts * Dataset: [sts](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb) at [f5a6f89](https://huggingface.co/datasets/Omartificial-Intelligence-Space/arabic-stsb/tree/f5a6f89da460d307eff3acbbfcb62d0705cdbbb5) * 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 | | | | * Samples: | sentence1 | sentence2 | score | |:--------------------------------------|:---------------------------------------|:------------------| | رجل يرتدي قبعة صلبة يرقص | رجل يرتدي قبعة صلبة يرقص. | 1.0 | | طفل صغير يركب حصاناً. | طفل يركب حصاناً. | 0.95 | | رجل يطعم فأراً لأفعى | الرجل يطعم الفأر للثعبان. | 1.0 | * Loss: [CosineSimilarityLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters: ```json { "loss_fct": "torch.nn.modules.loss.MSELoss" } ``` ### Training Hyperparameters #### Non-Default Hyperparameters - `eval_strategy`: steps - `per_device_train_batch_size`: 16 - `per_device_eval_batch_size`: 16 - `num_train_epochs`: 1 - `warmup_ratio`: 0.1 - `fp16`: True - `multi_dataset_batch_sampler`: round_robin #### All Hyperparameters
Click to expand - `overwrite_output_dir`: False - `do_predict`: False - `eval_strategy`: steps - `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 - `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`: 1 - `max_steps`: -1 - `lr_scheduler_type`: linear - `lr_scheduler_kwargs`: {} - `warmup_ratio`: 0.1 - `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`: 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`: 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 - `batch_sampler`: batch_sampler - `multi_dataset_batch_sampler`: round_robin
### Training Logs | Epoch | Step | Training Loss | sts loss | all-nli loss | sts-dev_spearman_cosine | sts-test_spearman_cosine | |:------:|:----:|:-------------:|:--------:|:------------:|:-----------------------:|:------------------------:| | 0.1389 | 100 | 0.5684 | 0.0279 | 1.0702 | 0.8484 | - | | 0.2778 | 200 | 0.5085 | 0.0289 | 0.9511 | 0.8446 | - | | 0.4167 | 300 | 0.4974 | 0.0283 | 0.9229 | 0.8430 | - | | 0.5556 | 400 | 0.4672 | 0.0293 | 0.9221 | 0.8378 | - | | 0.6944 | 500 | 0.4889 | 0.0300 | 0.8995 | 0.8360 | - | | 0.8333 | 600 | 0.4711 | 0.0303 | 0.8683 | 0.8330 | - | | 0.9722 | 700 | 0.4497 | 0.0291 | 0.8657 | 0.8410 | - | | 1.0 | 720 | - | - | - | - | 0.8173 | ### Framework Versions - Python: 3.9.18 - Sentence Transformers: 3.0.1 - Transformers: 4.42.4 - PyTorch: 2.2.2+cu121 - Accelerate: 0.26.1 - Datasets: 2.19.0 - Tokenizers: 0.19.1 ## Citation ### BibTeX #### Sentence Transformers and SoftmaxLoss ```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", } ```